October 17, 2018, 10:33:25 PM

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

Offline _PJ_

  • Jr. Member
  • **
  • Posts: 21
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???