About OutOfMemory Exception

While editing a psd file and save it into another file, after I use Image.setLayers function or Image.addLayer function, the memory used by PsdImage will not release even after I call Image.dispose(). The memory used will keep increasing while I repeat editing. How to free the memory occupied by PsdImage?

@Midas1990

Can you please share a working sample code reproducing the issue along with source file and also the memory profile images. We will try to investigate that further on our end on the basis of that.

 PsdImage loadImage = (PsdImage) Image.load(sourcePSDPath);

    List<Layer> layerList = new ArrayList<>();
    List<LayerGroup> groupList = groupLayers(loadImage.getLayers());

    PsdImage image = new PsdImage(loadImage);
    for (Layer layer : loadImage.getLayers()) {
        image.addLayer(layer);
    }
    image.save(targetPSDPath, new PsdOptions());

    image.dispose();

    loadImage.dispose();

Run the code above for a few times, memory is keep increasing.

@Midas1990

Can you please share the source file as well along with memory profile image that we may use on our end to investigate.

you can test with any psd file.

@Midas1990

I request you to please provide the memory profile image describing the memory not being released and increasing further in iterations.

before run the code before load and save.png
run the code 1 cycle 1st cycle.png (35.4 KB)
run the code 5 cycles 5 cycles.png (28.4 KB)
run the code 10 cycles10 cycles.png (25.8 KB)
run the code 20 cycles20 cycles.png (23.6 KB)
(32.1 KB)
I found if I remove line image.save(targetPSDPath, new PsdOptions()); the memory is not increasing.
My dependency is
com.aspose
aspose-psd
21.7
javadoc

    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-psd</artifactId>
        <version>21.7</version>
        <classifier>jdk16</classifier>
    </dependency>

@Midas1990

I have created a ticket with ID PSDJAVA-368 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be addressed.

thank you for your kindly support

Hi Mudassir, is there any feedback ?

Hi Mudassir, this issue is preventing us buying Aspose-PSD, we need to fix it as soon as possible.

@Midas1990

I regret to share that at present the issue is still not resolved. I request for your patience and we will share the good news with you as soon as the issue will be fixed.

Hi Mudassir,

Is there any feedback?

@Midas1990

I regret to share that at present the issue is still unresolved. We request for your patience and will share the good news with you as soon as it will be fixed.