* * *

Author Topic: [Solved] 1.8 Memory Issue - I Think  (Read 1151 times)

Hover

  • New member
  • *
  • Posts: 5
[Solved] 1.8 Memory Issue - I Think
« on: January 23, 2018, 02:57:43 am »
Hi, I have been away from Lazarus for several months, so I installed the latest 1.8 version using the deb packages on Sourceforge. I wiped everything Lazarus and FPC from the machine first, then locked the package manager so that it would not try to overwrite the installation with Debian repository packages.

I then started a new project using SDL, which is new to me,  and immediately ran into memory issues, with the machine locking up repeatedly. After beating my head against the wall for several days, I determined that everything was eating memory, or at least seemed to be.

So I did a full Debian update, rebuilt the IDE, and rebooted to a clean XFce4 desktop and started a new empty project (graphical application). I did nothing with it except enable the heaptrc unit. 

When I built and ran the empty project then immediately clicked on the form's close button, heaptrc showed 767 memory blocks allocated and freed. But when I dragged the empty form around rapidly for a few seconds, I got ghost trails and a heaptrc reading in the thousands of memory blocks allocated and freed.

I am not a professional programmer, far from it, but this seems very wrong to me. Any advice or insights would be very welcome.

Thanks,
Hover
« Last Edit: January 23, 2018, 05:38:11 pm by Hover »

taazz

  • Hero Member
  • *****
  • Posts: 5047
Re: 1.8 Memory Issue - I Think
« Reply #1 on: January 23, 2018, 04:05:54 am »
Hi, I have been away from Lazarus for several months, so I installed the latest 1.8 version using the deb packages on Sourceforge. I wiped everything Lazarus and FPC from the machine first, then locked the package manager so that it would not try to overwrite the installation with Debian repository packages.

I then started a new project using SDL, which is new to me,  and immediately ran into memory issues, with the machine locking up repeatedly. After beating my head against the wall for several days, I determined that everything was eating memory, or at least seemed to be.

So I did a full Debian update, rebuilt the IDE, and rebooted to a clean XFce4 desktop and started a new empty project (graphical application). I did nothing with it except enable the heaptrc unit. 

When I built and ran the empty project then immediately clicked on the form's close button, heaptrc showed 767 memory blocks allocated and freed. But when I dragged the empty form around rapidly for a few seconds, I got ghost trails and a heaptrc reading in the thousands of memory blocks allocated and freed.
that's how things work memory block are allocated when needed and free when they are not needed any longer as long as the total is 0 then you have leaks elsewhere.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

avra

  • Hero Member
  • *****
  • Posts: 1291
    • Additional info
Re: 1.8 Memory Issue - I Think
« Reply #2 on: January 23, 2018, 09:05:07 am »
I determined that everything was eating memory, or at least seemed to be.
Memory leaking or more memory spent then you would expect? How did you come to this conclusion? Show us heaptrc output on application exit. Does this happen on every example project from your Lazarus installation, or just with SDL2? What do you use for SDL2?
ct2laz - Easily convert components and projects between Lazarus and CodeTyphon

Hover

  • New member
  • *
  • Posts: 5
Re: 1.8 Memory Issue - I Think
« Reply #3 on: January 23, 2018, 05:12:35 pm »
Well, it was definitely leaking since the entire machine locked up.   :o

The good news is I traced the major culprit to the guy writing the program.  :-[   I forgot to destroy an SDL texture when it failed to load an image properly. The following load would generate a new texture using more memory.

The images come from an external source. Probably 2-3% or so are corrupt and fail to load. Currently, the application is loading five images a second, so it didn't take all that long to eat up the memory.

I also noticed that manual form movement increased project memory requirements, hence my original post. I don't really understand the internals of the Lazarus environment. It doesn't really matter though since it only happens in the IDE and has no impact on the final standalone program.

Thanks for the comments folks.

Edit: I am using these SDL2 headers. https://github.com/ev1313/Pascal-SDL-2-Headers
« Last Edit: January 23, 2018, 05:37:45 pm by Hover »

avra

  • Hero Member
  • *****
  • Posts: 1291
    • Additional info
Re: 1.8 Memory Issue - I Think
« Reply #4 on: January 23, 2018, 11:57:40 pm »
Well, it was definitely leaking since the entire machine locked up.
Your issue explanation was and still is misleading, since it sounded like your Lazarus 1.8 is leaking. I apologize if I interpreted it wrongly, but that was the impression I got. The whole point of my questions was to show you that you should first look for the issue source in your application and not in Lazarus, and if it was Lazarus then either included examples or minimal project showing the reproducible issue are needed for a bug report. Thankfully this was not a Lazarus issue.

Anyway, I am glad your problem is solved...
ct2laz - Easily convert components and projects between Lazarus and CodeTyphon

Hover

  • New member
  • *
  • Posts: 5
Re: [Solved] 1.8 Memory Issue - I Think
« Reply #5 on: January 24, 2018, 01:10:24 am »
No need to apologize, but there was nothing misleading at all. I thought Lazarus might be leaking, that's why I started the thread, very, very reluctantly I might add.

The form movement memory allocation linkage in the IDE is something I had never noticed before. I had already spent many hours going through my code trying to find out what the problem or problems were. Taazz's response was clear and I went right back to my code.

Isn't that what the forum is for?





« Last Edit: January 24, 2018, 01:20:27 am by Hover »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus