Memory Leak while Adding OLE Object Frame Using Aspose.Slides for Java

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

@Thilakbabu,
Thank you for reporting on the issue. I reproduced the memory leak you described.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESJAVA-39233

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Please also share the following additional information if it is possible:

  • OS version where the code was executed

OS version is Windows 11 Pro

Please keep us posted on the resolution.

Thanks.

@Thilakbabu,
Thank you for the additional information. I forwarded it to our developers.

You will be notified when the issue is resolved.

Hi @andrey.potapov

I see the issue status as Blocked… Could you please let us know a tentative ETA on when we can expect the fix for the memory leak ?

Thanks,
Thilak

@Thilakbabu,
I requested plans for the issue from our development team. We will let you know soon.

@Thilakbabu,
Our developers are working on the issue. A fix has been planned to be included in Aspose.Slides for Java 23.8. This release will be published in the second half of August.

Hi @andrey.potapov,

Please update once the fix is ready to be used.

@Thilakbabu,
As far as I can see, the fix will be included in Aspose.Slides for Java 23.8. You will be notified when this release is published.

The issues you found earlier (filed as SLIDESJAVA-39233) have been fixed in Aspose.Slides for Java 23.8 (JAR).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.

1 Like