You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a pretty large memory leak when adding multiple instances of Points, Shapes, or Lines.
Reproduce
When points(), shapes(), or lines() is called, it adds a Points, Shapes, or Lines instance to the global pointsInstances, shapesInstances, or linesInstances array. Each instance contains all of the layer information.
When .remove() is called on one the instances (for example: let pointLayer = glify.points({...}); pointLayer.remove()), the instance is not removed from the global instances array. This causes a very large memory leak when rendering and rerendering points many times, since the entire object for every render stays in memory after it has been removed.
A solution
My application must be able to rerender many points many times so I created a workaround. I think that this could be added to the .remove() method, unless I'm missing something.
Store an ID with the instance when creating it:
let pointLayer = glify.points({...});
const savedID = generateUniqueID(); // just needs to be unique across the instances
pointLayer.layerID = savedID;
When .remove()ing the instance, also remove it from the instance array manually:
It doesn't look like there have been any updates to the package since I created this issue so I don't think so, unless you are referring to something else. I'm probably going to PR a fix and add it to my fork
There is a pretty large memory leak when adding multiple instances of
Points
,Shapes
, orLines
.Reproduce
points()
,shapes()
, orlines()
is called, it adds aPoints
,Shapes
, orLines
instance to the globalpointsInstances
,shapesInstances
, orlinesInstances
array. Each instance contains all of the layer information..remove()
is called on one the instances (for example:let pointLayer = glify.points({...}); pointLayer.remove()
), the instance is not removed from the global instances array. This causes a very large memory leak when rendering and rerendering points many times, since the entire object for every render stays in memory after it has been removed.A solution
My application must be able to rerender many points many times so I created a workaround. I think that this could be added to the
.remove()
method, unless I'm missing something..remove()
ing the instance, also remove it from the instance array manually:The text was updated successfully, but these errors were encountered: