Local Declaration LIMITATION?

I am declaring some Audio file handlers and assigning them with audio.loadSound() but I’m hitting a limitation at 64 declarations. I then get an error when using Director class:

Director ERROR: Failed to load module ‘screen1’ - Please check if the file exists and it is correct."

I’ve been very careful, and if I comment out a later LOCAL declaration, I can add in another one… so it appears to be a quantity limitation?

Is this defined somewhere?

I have 63 of these declared at the top of my file, and if I add a 64th, I get the error…

local rascalBunter1Audio = audio.loadSound("./AUDIO/Bunter/AroundTheMoon.mp3")
[import]uid: 74844 topic_id: 13069 reply_id: 313069[/import]

That’s an awful lot of sounds you’re trying to load in to memory at the same time. You might be running in to a memory limitation. Have you tried loading all the sounds in a standalone project without director to see if an error still occurs? [import]uid: 27965 topic_id: 13069 reply_id: 48008[/import]

There is indeed. Here is some code to track memory usage:
[lua]local monitorMem = function()

collectgarbage()
print( "\nMemUsage: " … collectgarbage(“count”) )

local textMem = system.getInfo( “textureMemoryUsed” ) / 1000000
print( "TexMem: " … textMem )
end

Runtime:addEventListener( “enterFrame”, monitorMem )[/lua]
I grabbed this code from Jon Beebe’s article about memory management which you can find here:
http://jonbeebe.net/corona-sdk-memory-management-101-tag-memory-m [import]uid: 27965 topic_id: 13069 reply_id: 48018[/import]

OK, so I’m seeing:

MemUsage: 133.1181640625
TexMem: 2.609152 [import]uid: 74844 topic_id: 13069 reply_id: 48019[/import]

I know there is a 200 local variable and function limit per chunk. I’ve not seen a 64 variable limit. [import]uid: 19626 topic_id: 13069 reply_id: 48020[/import]

Hmm… Well it’s not a memory problem then. I would try it without Director if you can to find out if it’s a Director problem or Corona problem. Maybe there is indeed a limit on the amount of variables that can be used with Director (I doubt it’s a Corona limitation although it is possible). Perhaps someone that knows more (*cough* Ricardo *cough*) about the internals of Director could enlighten us? [import]uid: 27965 topic_id: 13069 reply_id: 48021[/import]

I’ll be stunned if it’s related to Director; but can we “flag” Ricardo within the thread? I might fire off an email to him. Something is afoot! :slight_smile: [import]uid: 74844 topic_id: 13069 reply_id: 48022[/import]

It very well could be a memory issue, I will investigate further. (To answer your question, no I have not tried without Director.) Is there an API call that would allow me to look at memory usage?
FYI: I checked and all my sounds total 7MB and should easily fit within RAM (I think). [import]uid: 74844 topic_id: 13069 reply_id: 48016[/import]

jerome82,

Please let us know if you figure out the problem as I’m sure many people would be interested in the answer (including myself). I know that decoding a lot of audio (especially mp3) can be quite a task for a mobile processor but 64 small audio files shouldn’t be too much of a problem. Obviously you can’t play them all at once but I wouldn’t think it would be a problem just loading them in to memory at the same time. [import]uid: 27965 topic_id: 13069 reply_id: 48068[/import]

Indeed the issue I was encountering was the 200 local variable limit. That’s information people should be aware of. [import]uid: 74844 topic_id: 13069 reply_id: 49971[/import]