Lua memory grows & comes down. Is it normal?

I try to print out the Lua memory used every 5 seconds by this line of code

local memUsage\_str = string.format( "MEMORY = %.3f KB", collectgarbage( "count" ) ) print( memUsage\_str)

and the output is following:

2013-12-25 20:02:17.680 Corona Simulator[55916:507] MEMORY = 1496.620 KB 2013-12-25 20:02:22.688 Corona Simulator[55916:507] MEMORY = 1597.093 KB 2013-12-25 20:02:27.696 Corona Simulator[55916:507] MEMORY = 1697.473 KB 2013-12-25 20:02:32.703 Corona Simulator[55916:507] MEMORY = 1797.853 KB 2013-12-25 20:02:37.712 Corona Simulator[55916:507] MEMORY = 1898.232 KB 2013-12-25 20:02:42.719 Corona Simulator[55916:507] MEMORY = 1998.612 KB 2013-12-25 20:02:47.727 Corona Simulator[55916:507] MEMORY = 2098.992 KB 2013-12-25 20:02:52.735 Corona Simulator[55916:507] MEMORY = 2199.372 KB 2013-12-25 20:02:57.742 Corona Simulator[55916:507] MEMORY = 2299.752 KB 2013-12-25 20:03:02.751 Corona Simulator[55916:507] MEMORY = 2400.132 KB 2013-12-25 20:03:07.758 Corona Simulator[55916:507] MEMORY = 2500.512 KB 2013-12-25 20:03:12.766 Corona Simulator[55916:507] MEMORY = 1994.880 KB 2013-12-25 20:03:17.775 Corona Simulator[55916:507] MEMORY = 1283.006 KB 2013-12-25 20:03:22.782 Corona Simulator[55916:507] MEMORY = 1383.386 KB 2013-12-25 20:03:27.790 Corona Simulator[55916:507] MEMORY = 1483.766 KB 2013-12-25 20:03:32.798 Corona Simulator[55916:507] MEMORY = 1584.146 KB 2013-12-25 20:03:37.806 Corona Simulator[55916:507] MEMORY = 1684.525 KB 2013-12-25 20:03:42.814 Corona Simulator[55916:507] MEMORY = 1784.905 KB 2013-12-25 20:03:47.822 Corona Simulator[55916:507] MEMORY = 1885.285 KB 2013-12-25 20:03:52.830 Corona Simulator[55916:507] MEMORY = 1985.665 KB 2013-12-25 20:03:57.837 Corona Simulator[55916:507] MEMORY = 2086.045 KB 2013-12-25 20:04:02.845 Corona Simulator[55916:507] MEMORY = 2262.923 KB 2013-12-25 20:04:07.853 Corona Simulator[55916:507] MEMORY = 2363.303 KB 2013-12-25 20:04:12.860 Corona Simulator[55916:507] MEMORY = 2463.683 KB 2013-12-25 20:04:17.868 Corona Simulator[55916:507] MEMORY = 2562.211 KB 2013-12-25 20:04:22.877 Corona Simulator[55916:507] MEMORY = 1245.923 KB 2013-12-25 20:04:27.884 Corona Simulator[55916:507] MEMORY = 1346.303 KB 2013-12-25 20:04:32.892 Corona Simulator[55916:507] MEMORY = 1446.683 KB 2013-12-25 20:04:37.900 Corona Simulator[55916:507] MEMORY = 1547.062 KB 2013-12-25 20:04:42.908 Corona Simulator[55916:507] MEMORY = 1647.442 KB 2013-12-25 20:04:47.915 Corona Simulator[55916:507] MEMORY = 1747.822 KB 2013-12-25 20:04:52.923 Corona Simulator[55916:507] MEMORY = 1848.202 KB 2013-12-25 20:04:57.931 Corona Simulator[55916:507] MEMORY = 1948.582 KB 2013-12-25 20:05:02.939 Corona Simulator[55916:507] MEMORY = 2048.962 KB 2013-12-25 20:05:07.947 Corona Simulator[55916:507] MEMORY = 2149.342 KB

(1) My app is total idle after launched. It stays in the first storyboard scene.

(2) I have checked I don’t have any timer.performWithDelay() running in the background

Although the LUA memory usage comes down after a while, why does it grow when the app is idle?

Is it normal?

Should I be wary about this?

It’s normal for your apps memory to grow and shrink while it’s running, but if your app is really idle, there shouldn’t be changes.  Something is using up to 1mb of memory and freeing it back up while you’re doing nothing.  So I’m curious about what is running in the background of your app.  Is it a physics app?  Do you have any Runtime listeners going?  Are you using any plugins?

Rob

I tried again with nothing but following code in main.lua

local function checkMemory() local memUsage\_str = string.format( "MEMORY = %.3f KB", collectgarbage( "count" ) ) print( memUsage\_str) end timer.performWithDelay( 5000, checkMemory, 0 )

I removed all pluging as well, and the log shows

2013-12-26 09:10:58.731 Corona Simulator[62551:507] MEMORY = 390.988 KB 2013-12-26 09:11:03.739 Corona Simulator[62551:507] MEMORY = 491.367 KB 2013-12-26 09:11:08.747 Corona Simulator[62551:507] MEMORY = 312.531 KB 2013-12-26 09:11:13.755 Corona Simulator[62551:507] MEMORY = 412.910 KB 2013-12-26 09:11:18.763 Corona Simulator[62551:507] MEMORY = 513.289 KB 2013-12-26 09:11:23.770 Corona Simulator[62551:507] MEMORY = 297.914 KB 2013-12-26 09:11:28.778 Corona Simulator[62551:507] MEMORY = 398.293 KB 2013-12-26 09:11:33.787 Corona Simulator[62551:507] MEMORY = 498.672 KB 2013-12-26 09:11:38.795 Corona Simulator[62551:507] MEMORY = 282.754 KB 2013-12-26 09:11:43.802 Corona Simulator[62551:507] MEMORY = 383.133 KB 2013-12-26 09:11:48.810 Corona Simulator[62551:507] MEMORY = 483.512 KB 2013-12-26 09:11:53.818 Corona Simulator[62551:507] MEMORY = 267.520 KB 2013-12-26 09:11:58.826 Corona Simulator[62551:507] MEMORY = 367.846 KB 2013-12-26 09:12:03.834 Corona Simulator[62551:507] MEMORY = 468.225 KB 2013-12-26 09:12:08.842 Corona Simulator[62551:507] MEMORY = 561.068 KB 2013-12-26 09:12:13.850 Corona Simulator[62551:507] MEMORY = 352.932 KB 2013-12-26 09:12:18.857 Corona Simulator[62551:507] MEMORY = 453.311 KB 2013-12-26 09:12:23.865 Corona Simulator[62551:507] MEMORY = 553.689 KB 2013-12-26 09:12:28.873 Corona Simulator[62551:507] MEMORY = 338.436 KB 2013-12-26 09:12:33.880 Corona Simulator[62551:507] MEMORY = 438.814 KB 2013-12-26 09:12:38.888 Corona Simulator[62551:507] MEMORY = 539.193 KB

So I guess it’s normal for lua memory grows & shrinks while the app is idle?

PS. my app is not a physics app, and it has Runtime listeners for “system” “orientation” “key” “memoryWarning”. I do have plugins for “social popup” “flurry” “iad” “admob” 

It’s normal for your apps memory to grow and shrink while it’s running, but if your app is really idle, there shouldn’t be changes.  Something is using up to 1mb of memory and freeing it back up while you’re doing nothing.  So I’m curious about what is running in the background of your app.  Is it a physics app?  Do you have any Runtime listeners going?  Are you using any plugins?

Rob

I tried again with nothing but following code in main.lua

local function checkMemory() local memUsage\_str = string.format( "MEMORY = %.3f KB", collectgarbage( "count" ) ) print( memUsage\_str) end timer.performWithDelay( 5000, checkMemory, 0 )

I removed all pluging as well, and the log shows

2013-12-26 09:10:58.731 Corona Simulator[62551:507] MEMORY = 390.988 KB 2013-12-26 09:11:03.739 Corona Simulator[62551:507] MEMORY = 491.367 KB 2013-12-26 09:11:08.747 Corona Simulator[62551:507] MEMORY = 312.531 KB 2013-12-26 09:11:13.755 Corona Simulator[62551:507] MEMORY = 412.910 KB 2013-12-26 09:11:18.763 Corona Simulator[62551:507] MEMORY = 513.289 KB 2013-12-26 09:11:23.770 Corona Simulator[62551:507] MEMORY = 297.914 KB 2013-12-26 09:11:28.778 Corona Simulator[62551:507] MEMORY = 398.293 KB 2013-12-26 09:11:33.787 Corona Simulator[62551:507] MEMORY = 498.672 KB 2013-12-26 09:11:38.795 Corona Simulator[62551:507] MEMORY = 282.754 KB 2013-12-26 09:11:43.802 Corona Simulator[62551:507] MEMORY = 383.133 KB 2013-12-26 09:11:48.810 Corona Simulator[62551:507] MEMORY = 483.512 KB 2013-12-26 09:11:53.818 Corona Simulator[62551:507] MEMORY = 267.520 KB 2013-12-26 09:11:58.826 Corona Simulator[62551:507] MEMORY = 367.846 KB 2013-12-26 09:12:03.834 Corona Simulator[62551:507] MEMORY = 468.225 KB 2013-12-26 09:12:08.842 Corona Simulator[62551:507] MEMORY = 561.068 KB 2013-12-26 09:12:13.850 Corona Simulator[62551:507] MEMORY = 352.932 KB 2013-12-26 09:12:18.857 Corona Simulator[62551:507] MEMORY = 453.311 KB 2013-12-26 09:12:23.865 Corona Simulator[62551:507] MEMORY = 553.689 KB 2013-12-26 09:12:28.873 Corona Simulator[62551:507] MEMORY = 338.436 KB 2013-12-26 09:12:33.880 Corona Simulator[62551:507] MEMORY = 438.814 KB 2013-12-26 09:12:38.888 Corona Simulator[62551:507] MEMORY = 539.193 KB

So I guess it’s normal for lua memory grows & shrinks while the app is idle?

PS. my app is not a physics app, and it has Runtime listeners for “system” “orientation” “key” “memoryWarning”. I do have plugins for “social popup” “flurry” “iad” “admob”