Malloc log: what is active memory?

I'm trying to understand the malloc log, to verify whether memory held by an Object is actually cleared.

In the test scenario, multiple large images are created, all with a unique size so they can be easily found in the memory logs. I attached the entire test scenario as a single image, so that the malloc log can be matched to the line numbers in the malloc log. (note that the largest object is correctly identified as originating from line 48)

All of this is run on simulator with the 16MB pool enabled (Mac, sdk 1.13.0)

Questions:

Q1: what does the "active" column mean?

I would guess memory that is still allocated at the moment the log was created. This is consistent with line 48 being active and the lines 46 and 47 not being active anymore because they were assigned to the same variable globalImage. It is not consistent with the images being held by the Testclass(es). While one of the TestClasses might be cleaned up due to it being removed in line 44, the remaining testClass should still hold the memory for the two images it has. That the images are still available to lua is shown in the console.

Q2: Why is the memory for the first TestClass (created on line 42) not marked as active?

Q3: So, is the memory for the second TestClass (created on line 43, removed on line 44) available for re-use or not?

The Malloc Log window only tracks C allocations, what you're looking at is lua which is tracked by garbage collection. You can see the active Lua memory in the Lua Memory window. Hope this helps.

Thanks, the Lua Memory does show global variables, but local images do not show up:

If I change testClasses to be global, I see this:

So I guess I can conclude that this works as expected? The memory allocated for line 43 can be reused?

Yes, the memory alloc'd for TestClass() which is removed on line 44 should reclaimed by garbage collection and reused.