memory leak in MolExporter for svgs

User ebc1e6aaea

12-02-2015 05:36:07

Hi,

There seems to be a memory leak for SVG exporting with MolExporter.  I can demonstrate that with the following simple loop.  The heap size quickly grows to several GB's.  This does not happen with other formats such as PNG.



String methane = "\n\n\n  1  0  0  0  0  0  0  0  0  0999 V2000\n   -0.2678    0.9486    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\nM  END";
Molecule m = MolImporter.importMol(methane);
for (int i=0; i<100000; i++) {
    MolExporter.exportToFormat(m, "svg:nosource");
}

Brian

ChemAxon 4fa3cf533c

12-02-2015 12:59:10

Dear Brian, 


Thank you for reporting this issue. We've filed a ticket in our issue reporting system for this, and will look into it.


Regards,


Tamas Fazekas-Vigh

ChemAxon 2c555f5717

16-02-2015 15:44:54

Dear Brian,


   I have run several test with the code you have sent to me, and the latest available version of Marvin (MarvinBeans 15.2.9) and could not find any memory leak. It is true that generating the svg-s can eat up all the memory but they are not used Strings that can be garbage collected as soon as more memory is required. The same code could run with maximum heap size 256 MB, 1 GB, 2 GB, and no crash or behavioral anomaly has happened.


   The difference between png and svg export is the output: the first one generates a byte array, and the second one generates a String output that is handled differently. Did you find any problem in your code that was tracked down to the memory usage of svg export?


Regards:
Balázs