A few memory leaks

we have a scenario where we keep opening and closing goJS based diagram editors.

one of the problems is that each time there are a few “leaks” related to goJS:

these seem to be just some left over objects… and the bulk of goJS stuff properly disposes.

as a note… none of the used model classes are still in memory… so they are not retained by our stuff (or at least not in a very clear way)

oh… forgot to say… this is goJS 2.0.2.

My guess is that those are cached images. Do you have any Pictures in your diagrams?

If so, I suppose you could call the static function Picture.clearCache with no arguments.

well… that didn’t seem to have any effect… :(

Does the number of extraneous HTMLImageElements increase as you open/use/release Diagrams?

Internally we do have a few DOM elements that we use – for example for measuring text. But the number should not increase even if there are many Diagrams in use simultaneously, nor will they be released if there are no longer any Diagrams at all.

between 2 instances we get like 16 new Detached HTMLImageElement and 8 new Detached SVGGElement… and a lot of other type of detached elements… but these two seem like the only ones that would be related to goJS… (like we get 507 new Detached HTMLDivElement)

couldn’t find any direct link from any of them to goJS tho… looked at the entire retainer tree of one of the images… nothing.

Unless you are asking us to render SVG (e.g. by calling Diagram.makeSvg), GoJS does not create any SVG DOM elements.

Upon a quick review of our code, I believe we create two tiny HTMLImageElements as “static” variables, to which we retain references indefinitely. Of course we may create any number of HTMLImageElements, depending on how many Pictures and URLs your diagram uses.

Wait-- 2.0.2 had a problem with managing SVG DOM elements – try upgrading to latest.

And if you updated today, please update again, there was a TypeScript definitions file issue in 2.0.5.

2.0.6 is now latest.