tableviews and memory leaks

Hi,

I am tackling with my first attempt of memory leak checking on my first app. I check it by using this function I found:

function checkMemory (event)    collectgarbage("collect")    local memUsage\_str = string.format( "MEMORY= %.3f KB", collectgarbage( "count" ) )    print( memUsage\_str .. " | TEXTURE= "..(system.getInfo("textureMemoryUsed")/1048576) ) end     Runtime:addEventListener("tap", checkMemory)

I noticed this behavior in my two scenes:

In the first scene I have a tableview that generates rows on user input and stores rows’ data in a in-memory table.

In the other scene I have another tableview that displays rows from an sql file (which store persistently data generated in scene1).

If I jump from scene 1 to 2 without performing any in scene action I don’t see any significant increase in memory usage (if at all).

If I start adding rows to the non-persistent and/or to the persistent tableview  memory usage goes up with the number of rows displayed in each.

Is this normal behavior or memory leak?

I start at an average memory usage of 500kb and if the tableviews get filled heavily it goes over 1000kb, is this too much considered that it’s a very simple utility app?

Thanks!!!

Hi @akak,

This scenario could be tricky to pinpoint if there’s any memory leak. Table views only display the rows which are on screen or “about to come on screen” so it’s reasonably logical that you won’t see any massive fluctuation between memory levels.

The best approach is to follow the typical rule on detecting potential memory leaks: if the memory level continues to climb and never drops back down near the initial level when you navigate between scenes for awhile, then you probably have a leak. If it fluctuates around the same level, only with minor variances, there probably is no leak.

Take care,

Brent

Hi @akak,

This scenario could be tricky to pinpoint if there’s any memory leak. Table views only display the rows which are on screen or “about to come on screen” so it’s reasonably logical that you won’t see any massive fluctuation between memory levels.

The best approach is to follow the typical rule on detecting potential memory leaks: if the memory level continues to climb and never drops back down near the initial level when you navigate between scenes for awhile, then you probably have a leak. If it fluctuates around the same level, only with minor variances, there probably is no leak.

Take care,

Brent