March 26, 2019, 09:03:17 AM

Author Topic: Free assert memory allocation  (Read 326 times)

Offline _PJ_

  • Jr. Member
  • **
  • Posts: 22
Free assert memory allocation
« on: June 27, 2018, 06:35:03 PM »
I'm positive this is a subject that has been raised numerous times in the past, but any searches have not adequately addressed the issue as it stands for my particular purpose.

The problem is this:

I need something of an equivalent to the "FreeImage" commands (a la B3D / B+) - Note this is nothing to do with the similarly named module nor DLL)

Typically, the 'goto' response would involve suggestions of how simply using lists and/or allowing the GC collector to take care of such things automatically - This unfortunately does not seem to be appropriate in the circumstance.

To explain, here's a brief summary of the process in a MAXGUI APP

1) USER selects filepath to an image with RequestFile
2) Image is LOADED as "TPixmap" object - this is a GLOBAL object
3) --- stuff ---
4) If the USER then chooses to LOAD another object (intended to OVERWRITE previous) - there needs to be a means to FREE the previous Pixmap - otherwise, this poses a memory leak.

There will ONLY EVER BE need for a SINGLE image (TPixmap) in memory at any one time.


Is the solution TRULY to create a list for TPixmaps and only refer to the most recent one, and have fath the GC will "know" to remove any old ones???