cheminfo / openchemlib-js

JavaScript port of OpenChemLib
https://cheminfo.github.io/openchemlib-js/index.html
BSD 3-Clause "New" or "Revised" License
71 stars 20 forks source link

Molfile creation is done by appending lines #184

Open lpatiny opened 7 months ago

lpatiny commented 7 months ago

I have an issue with the creation of molfile in memory. I'm creating 2500 molfile but in the memory heap snapshot it seems I have 9000000 entries

image

I think that in memory we keep all the different length of the string obtained during creation / concatenation:

https://github.com/cheminfo/openchemlib/blob/23bd145d76f2be249ea279415e2c59e54c965fba/src/main/java/com/actelion/research/chem/MolfileCreator.java#L201-L228

Does this makes sense ?

Is there a way to 'clean' the memory like doing something like JSON.parse(JSON.stringify(molfile)) ?

@targos WDYT ?

lpatiny commented 7 months ago

Need to check if flatstr (https://github.com/davidmarkclements/flatstr/blob/master/index.js) helps

targos commented 7 months ago

If it does, I suggest to create an issue in the V8 tracker: https://bugs.chromium.org/p/v8/issues/list