Recent

Author Topic: Must I dispose heaped items when ending the program?  (Read 1472 times)

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8729
  • FPC developer.
Re: Must I dispose heaped items when ending the program?
« Reply #15 on: June 29, 2020, 09:59:57 pm »
marcov, Which OS do you target?  I've had to add proper cleanup to my code or a (memory allocation error)  message pop is generated by windows OS.

It is not Windows. That are your lazarus settings (heaptrc/-gh).

Quote
I know you know, but for others... as posted before, you should allocate in backwards order to the allocation so your for loop should be
Code: Pascal  [Select][+][-]
  1. for i= some.count-1 down to 0
  2.    some[i].free;
  3.  

Could you explain the motivation for that backwards order ? Since you say it is necessary, I'm sure you can explain why.

Oh, and btw, I didn't specify what TYPE "some" was.. So some might not be a linear list at all.

And most importantly, you miss the point. there should be an exception handler around the free, inside the for.
« Last Edit: June 29, 2020, 10:57:22 pm by marcov »

AlanTheBeast

  • Jr. Member
  • **
  • Posts: 73
Re: Must I dispose heaped items when ending the program?
« Reply #16 on: June 29, 2020, 10:45:12 pm »

Its like who cares, I test my work in production.....

Microsoft, Apple, Samsung, ... they don't?

mas steindorff

  • Sr. Member
  • ****
  • Posts: 444
Re: Must I dispose heaped items when ending the program?
« Reply #17 on: June 30, 2020, 12:38:33 am »
I'm not sure were the message came from.  it was only on a few computers that all ran the image of my software but looked like it was part of the OS as appose to an antivirus or like.  I did not pursue the issue (of who generated it) since I had one of the computers at my disposal for a short time and it was a simple mater to add cleanup code.  I later read there is a developer's setting in windows that may have been enabled.  I do not know if it was protecting itself or trying to help me  %)
My software needed to run on whatever windows OS the clients had so I just added the cleanup code.

edited: no, it was not the heap check.  1st thing I checked.  I have it turned off for "release" mode builds and the final images have different names so I do not confuse them.  I know it's not a give but I also ran the same exe on the different computers the same way (as close as I could) and only got the message on one computer (in house).  the original bug report generated by a customer was my 2nd computer.  I do not know how many others there was since some time they don't care that much about bug after they have what they came for.
 
« Last Edit: June 30, 2020, 12:46:33 am by mas steindorff »
windows 7/10 - laz 2.0 / 1.2.6 general releases

 

TinyPortal © 2005-2018