Hi Team,
I am trying to create a ppt with OLE object frame containing an excel of 2 Million cells (50*40000).
For each iteration I could see around 180 Mbs of leak and we try to run this for 20 iterations, we see a total of around 3.5 Gbs of leak.
Aspose versions used are
Aspose cells - 23.2
Aspose slides - 23.2
Java version - Amazon coretto jdk11
Below is the code which I ran
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
import com.aspose.cells.WorksheetCollection;
import com.aspose.slides.IOleEmbeddedDataInfo;
import com.aspose.slides.IOleObjectFrame;
import com.aspose.slides.ISlide;
import com.aspose.slides.OleEmbeddedDataInfo;
import com.aspose.slides.Presentation;
import com.aspose.slides.SlideSizeScaleType;
import java.io.ByteArrayOutputStream;
import java.text.NumberFormat;
public class TestOLE {
public static void main(String[] args) throws InterruptedException {
memory(0);
for (int i = 0; i < 20;) {
extracted();
memory(++i);
}
}
private static void extracted() {
Workbook workbook = new Workbook();
Presentation pres = new Presentation();
try (final ByteArrayOutputStream bout = new ByteArrayOutputStream()) {
WorksheetCollection sheetCollection = workbook.getWorksheets();
Worksheet worksheet = sheetCollection.get(0);
for (int col = 0; col < 50; col++) {
for (int row = 0; row < 40000; row++) {
worksheet.getCells().get(row, col).setValue(col + ":" + row);
}
}
workbook.getWorksheets().setOleSize(0, 25, 0, 9);
workbook.save(bout, com.aspose.cells.SaveFormat.XLSX);
pres.getSlideSize().setSize(960, 540, SlideSizeScaleType.DoNotScale);
ISlide slide = pres.getSlides().get_Item(0);
IOleEmbeddedDataInfo dataInfo = new OleEmbeddedDataInfo(bout.toByteArray(), "xlsx");
IOleObjectFrame oof = slide.getShapes().addOleObjectFrame(50, 20, 700, 330, dataInfo);
} catch (Exception e) {
e.printStackTrace();
} finally {
workbook.dispose();
pres.dispose();
}
}
private static void memory(final int iteration) {
final Runtime runtime = Runtime.getRuntime();
final NumberFormat format = NumberFormat.getInstance();
final StringBuilder sb = new StringBuilder();
System.gc();
final String bytes = format.format(runtime.totalMemory() - runtime.freeMemory());
sb.append("Iteration: " + iteration);
sb.append(" Used memory: " + bytes + " Bytes");
System.out.println(sb.toString());
}
}
The console output looks like below
Iteration: 0 Used memory: 16,800,824 Bytes
Iteration: 1 Used memory: 218,976,920 Bytes
Iteration: 2 Used memory: 395,427,560 Bytes
Iteration: 3 Used memory: 571,875,560 Bytes
Iteration: 4 Used memory: 748,325,384 Bytes
Iteration: 5 Used memory: 924,772,512 Bytes
Iteration: 6 Used memory: 1,101,218,808 Bytes
Iteration: 7 Used memory: 1,277,666,088 Bytes
Iteration: 8 Used memory: 1,454,111,504 Bytes
Iteration: 9 Used memory: 1,630,557,656 Bytes
Iteration: 10 Used memory: 1,807,003,584 Bytes
Iteration: 11 Used memory: 1,983,448,688 Bytes
Iteration: 12 Used memory: 2,159,893,920 Bytes
Iteration: 13 Used memory: 2,336,339,336 Bytes
Iteration: 14 Used memory: 2,512,787,680 Bytes
Iteration: 15 Used memory: 2,689,233,112 Bytes
Iteration: 16 Used memory: 2,865,678,584 Bytes
Iteration: 17 Used memory: 3,042,124,880 Bytes
Iteration: 18 Used memory: 3,218,570,280 Bytes
Iteration: 19 Used memory: 3,395,015,840 Bytes
Iteration: 20 Used memory: 3,572,806,328 Bytes
This is causing a huge memory leak in our production environment.
Please provide us a resolution ASAP on this. Also let me know if you need any other info from my end.
Thanks,
Thilak