vue-grid-layout icon indicating copy to clipboard operation
vue-grid-layout copied to clipboard

Memory leak

Open Freeandeasy101 opened this issue 2 years ago • 0 comments

I found a function called cloneLayoutItem in the source code that uses JSON.parse(JSON.stringify). Normally, there shouldn't be any issues with this approach. However, when dragging elements and having a large amount of data in the layout, it can lead to a memory spike. I would like the author to optimize this aspect.

Code:

function cloneLayoutItem(layoutItem /: LayoutItem/ ) /: LayoutItem/ { /return { w: layoutItem.w, h: layoutItem.h, x: layoutItem.x, y: layoutItem.y, i: layoutItem.i, minW: layoutItem.minW, maxW: layoutItem.maxW, minH: layoutItem.minH, maxH: layoutItem.maxH, moved: Boolean(layoutItem.moved), static: Boolean(layoutItem.static), // These can be null isDraggable: layoutItem.isDraggable, isResizable: layoutItem.isResizable };/ return JSON.parse(JSON.stringify(layoutItem)); }

Please optimize the code to address the memory issue caused by excessive data in the layout when dragging elements.

Freeandeasy101 avatar Oct 30 '23 04:10 Freeandeasy101