vue-grid-layout
vue-grid-layout copied to clipboard
Memory leak
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.