Page 1 of 1

Possible memory leak on drag

Posted: Tue Feb 09, 2016 1:24 pm
by neville
I seem to be getting a memory leak (about 1 MB) when dragging an image (LiveCode 7.1.1) using code

on dragStart
....
put the long ID of the target into tObj
export snapshot from tObj to tVar as PNG

set the width of img "DragImage" to the width of tObj
set the height of img "DragImage" to the height of tObj
set the visible of image "DragImage" to false
put tVar into img "DragImage"

put the clickH - the left of the target into xOffset
put the clickV - the top of the target into yOffset
set the dragImageOffset to xOffset,yOffset
set the dragImage to the short id of img "DragImage"
set the dragData["private"] to gridCoords(item 1 of the loc of the target,item 2 of the loc of the target)
---

dragMove does nothing unusual, just sets the dragAction to either "none" or "move"

There is also an Xcode console message

LiveCode-Community[13158:1963210] _DPSDiscardEvents: FlushEventsMatchingListFromQueue returned error (-50)

which appears at the start of the drag (possibly indicating an event reference being lost?) I was debugging an external when I found this - the external is not being called when the leak and console message occur however.

Any ideas?

Re: Possible memory leak on drag

Posted: Tue Feb 09, 2016 5:46 pm
by FourthWorld
You may want to test that script in the latest development version, 8.0 DP14. It may have already been fixed (some work was done with drag-and-drop recently), but if not they'll want to see a bug report on that so they can take care of it right away.

Re: Possible memory leak on drag

Posted: Wed Feb 10, 2016 1:45 am
by neville
It does appear to happen in LC 8 p14 --- Leaks instrument is slightly confusing because there seems to be a memory leak in dp14 which occurs even before my stack opens. The Console definitely still reports the FlushEvents error on each dragStart. I have constructed a test stack with just a draggable object to isolate from my external code as a bug report; it does seem to be an LC library memory leak in drag, or possibly the pasteboard operation when creating the dragImage.

Re: Possible memory leak on drag

Posted: Wed Feb 10, 2016 2:08 am
by FourthWorld
Thanks for testing that. You can file a report with your details and a recipe here:
http://quality.livecode.com/

Re: Possible memory leak on drag

Posted: Sat Feb 13, 2016 3:04 am
by neville
Confirmed [Bug 16893] present since LC6.7.x

Re: Possible memory leak on drag

Posted: Sat Feb 13, 2016 6:21 pm
by jacque
Nice work Neville. I think this will fix a lot of issues. Thanks for reporting it.