Given the OS is responsible for allocating memory, it would make sense for the OS to release the memory when the application closes, yes?
Yes, the OS does free up all application memory upon application termination. What it doesnât do is keep your app from using ALL of the possible memory for an application.
Memory housekeeping is up to the programmer.
âStaticâ leaks - memory allocated once and never freed are not optimal, but wonât crash your app. This memory will be silently freed at app termination.
Dynamically allocated memory, if done enough times without freeing, will eventually eat all of your available memory and your app will crash. This memory will be freed by the OS, right after your app crashes.
My post was in reply to " The other option is a TList containing all created objects that gets cleared when the application closes. "
I totally agree with skydvrzKevin G. McCoy
Example: application makes an object that uses 30 kb of RAM with a process the user is using Sometimes thatâs repeated a lot of times = a lot of times * 30 kb
So this is repeated is a loss of RAM for another use. How a user complains loosing a few gigs!!! especially when the app continually runs and the computer is put on standby
I was thinking CheckCreate(Var NewObjectPtr: TObject; NoAllowedObjects: integer default 0) ; virtual; Override; // 0 means unlimited objects
does not have to be part of TObject,
Free&Nil can also be free of being part of TObject,
Just stand alone procedures but the CheckCreate must check match if object pointer to object that can be done with the âisâ Statement !!!