How much memory is too much memory?

memUsage = 120 KB

texMemUsage = 2000 (sometimes 5000) MB

Can somebody explain the difference between the two and whether my texMem is too high. I am using storyboard [import]uid: 75779 topic_id: 25838 reply_id: 325838[/import]

How long is a piece of string :slight_smile:

But seriously it’s hard to say due to the differences in devices. I generally work to the principle of making things as small as possible without sacrificing the concept, and then if I have to, worry about optimisation after that.

FWIW I really don’t think you’re using 2-5GB of texture memory, that’s probably representative of KB - unless of course you’re making the biggest, most sublime App ever built on Corona - that wouldn’t have a hope of actually running on any device :slight_smile:

If it is 2-5MB instead then that’s nothing to worry about, and the imprint on system memory is negligible.
[import]uid: 33275 topic_id: 25838 reply_id: 104482[/import]

Actually it says I’m using 2220.032 MB texMem

could it be a memory leak causing 2gigs of memory loss.

I haven’t tried on any device yet.
[import]uid: 75779 topic_id: 25838 reply_id: 104503[/import]

If you truly have 2GB of memory in use, you have a major problem. The best devices only have 1GB of memory with only about 1/3-1/2 of that available for your apps. The average devices will only have 0.5GB of memory.

I’m surprised that the simulator hasn’t choked yet. Thats a lot of texture memory even for a computer to deal with.

The 120KB of Lua memory is insignificant in the grand scheme of things, you just don’t want it continuing to increase and not go back down.
If you plan to support devices like the iPhone 3GS and iPad 1, which only have 256MB of memory (0.25GB) then your texture memory should probably stay below 100MB at the max and preferably less. [import]uid: 19626 topic_id: 25838 reply_id: 104518[/import]

Can you post your code for your memory check function, just to make certain that is GB?

If it is definitely GB’s then you really need to reduce those assets, like Rob says it’s never going to work like that. I’d be really interested to know what size assets you are using - dimensions, disk space, dpi, etc…
[import]uid: 33275 topic_id: 25838 reply_id: 104609[/import]

Here is my memory code. I copied and pasted from Jon Beebe storyboard
[lua]–main
display.setStatusBar( display.HiddenStatusBar )
local storyboard = require ‘storyboard’

storyboard.gotoScene(‘title’)
local function garbagePrinting()
collectgarbage(“collect”)
local memUsage_str = string.format( “memUsage = %.3f KB”, collectgarbage( “count” ) )
print( memUsage_str )
local texMemUsage_str = system.getInfo( “textureMemoryUsed” )
texMemUsage_str = texMemUsage_str/1000
texMemUsage_str = string.format( “texMemUsage = %.3f MB”, texMemUsage_str )
print( texMemUsage_str )
end

Runtime:addEventListener( “enterFrame”, garbagePrinting )
–]][/lua]

I added up all the images KB by hand and it came out to like 5000KB. Would that number be representative of the texMemUsage?

[import]uid: 75779 topic_id: 25838 reply_id: 104646[/import]

System.getInfo returns bytes. You are dividing by 1000 (really should be 1024) which is giving you kilobytes (KB). You should divide the number by (1024x1024) to get megabytes.

So you are really only using around 2MB of texture memory which seems really low

[import]uid: 19626 topic_id: 25838 reply_id: 104648[/import]

That’s more like it… :slight_smile: [import]uid: 33275 topic_id: 25838 reply_id: 104656[/import]

Aha! Thanks guys! [import]uid: 75779 topic_id: 25838 reply_id: 104664[/import]

Here is a function i made that prints memory usage data cleaner:

local function printMemUsage()  
 collectgarbage("collect")  
  
 local memUsed = (collectgarbage("count")) / 1000  
 local texUsed = (system.getInfo("textureMemoryUsed")) / 1000000  
  
 print("\n---------MEMORY USAGE INFORMATION---------")  
 print("System Memory Used:", string.format("%.03f", memUsed), "Mb")  
 print("Texture Memory Used:", string.format("%.03f", texUsed), "Mb")  
 print("------------------------------------------\n")  
  
 return true  
end  

That will print out data neatly eg

---------MEMORY USAGE INFORMATION---------  
System Memory Used: 0.168 Mb  
Texture Memory Used: 1.040 Mb  
------------------------------------------  

as opposed to the likes of

[code]
---------MEMORY USAGE INFORMATION---------
System Memory Used: 0.16830340393 Mb
Texture Memory Used: 1.040000 Mb

[/code] [import]uid: 84637 topic_id: 25838 reply_id: 104670[/import]