Menu

#35 SpkToolbar memory leak on window resize

v1.0 (example)
closed-fixed
wp
1
2024-01-04
2017-10-06
No

SpkToolbar has a serious memory leak which occurs on every single window resize. After a lot of resizes the program freezes.
Test it using the demo "spktoolbar\demos\actions\Project1.lpi".
I used the latest version, on Windows 10 64 bit.

Discussion

  • wp

    wp - 2017-10-11

    I cannot reproduce this. Please give EXACT steps what to do to see the bug.

    Which Lazarus/fpc version? Is Lazarus 64 bit as well?

     
  • Constantinos Velissariou

    Lazarus version=1.9.0 2017-08-19
    FPC version=3.1.1
    SVN Revision 55677M

    1. Open project spktoolbar\demos\actions\project1.lpi
    2. Build and run program
    3. Open task manager to watch memory size of project1.exe
    4. Use the mouse to grab the right border of the application window and start increasing and decreasing the width of the window.
    5. Notice at the task manager that the size of memory of project1.exe increases.
     
  • wp

    wp - 2017-10-11

    Out of luck - the Taskmanager trace stays flat, How fast does it increase? Do you observe the same with a new program to which you just add an empty TSpkToolbar? If not: Which SpkToolbarControl do have to add to see the effect?

    BTW: The taskmanager is not the right tool to look for memory leaks because it shows all memory allocations, not only those of the program under test. Usually we check for memory leaks by checking the UseHeapTrc option in the project options; when the program ends a dialog pops up which lists the lines in which unfreed memory is allocated. (http://wiki.lazarus.freepascal.org/heaptrc).

     
  • Constantinos Velissariou

    I think I found out why you don't see any leak. Please goto "advanced system settings" -> "performance settings" and check "show window contents while dragging".
    I made some experiments starting with an empty form and then adding a spkToolbar then spkTab etc.
    My conclusion is that when images are connected to spkLargeButtons (and window contents are shown while dragging) there is memory leak. According to task manager the program starts with 3.2 MB and when the size reaches 40 MB there is an error "Canvas does not allow drawing". I have attached some screenshots.

     
  • wp

    wp - 2017-10-11

    It has been checked all the time, and when dragging I see the full window moving, not just the border.

    I am testing with a newer Laz-trunk version and with fpc 3.0.4RC. Any chance that you could try Laz 1.8/RC4? I don't see a memory leak with it either. Make a secondary installation to leave your normally used version alone. In the meantime I try to update my fpc trunc installation (I always hate this...).

     

    Last edit: wp 2017-10-11
  • wp

    wp - 2017-10-11

    OK I see it now, I did not look at the process list, I only looked at the graph which has too poor resolution, and I also get the crash near 40 MB. The heaptrc output which comes after the crash, however, is just a consequence of the crash, if I close the program regularly there is no memory leak. Therefore I think this bug is not a classical memory leak but indicates running out of handles.

     
  • wp

    wp - 2017-10-12

    Please test the current revision.

     
  • Constantinos Velissariou

    Problem solved.
    Thanks a lot !!

     
  • wp

    wp - 2024-01-04
    • status: open --> closed-fixed
    • assigned_to: wp
     

Log in to post a comment.

MongoDB Logo MongoDB