Page 1 of 2
app crashing
Posted: Tue Jan 14, 2014 3:46 pm
by teacherguy
What impact do global variables play in terms of memory, speed of app, and so on? The app I am working on (a simple rhythm game) tends to crash after about 15 minutes of play. I am wondering if the globals could play a role? Or is there some other sort of buffer that needs to be cleared out?
Re: app crashing
Posted: Tue Jan 14, 2014 4:11 pm
by Klaus
HI teacherguy,
unless you put a couple of MBs into a lot of global variables, that should not be the problem.
So we need a TAD more info about your app
Best
Klaus
Re: app crashing
Posted: Tue Jan 14, 2014 4:23 pm
by teacherguy
Thanks Klaus. In each "round" a rhythm is generated (I play some caf files and use "wait with messages"… simple stuff), and the user drags buttons that have icons on them that represent the rhythm heard. The button order is evaluated when the user submits their answer.
Since the app never crashes early on, something seems to be building up somewhere…. I keep that total score in a variable, but that would never amount to anything. I store the locations of the sounds in variables…but those are just paths. Is there an audio buffer that needs to be cleared? I don't know what else to look for.
Re: app crashing
Posted: Tue Jan 14, 2014 4:53 pm
by Klaus
HI teacherguy,
teacherguy wrote: Is there an audio buffer that needs to be cleared?
not that I knew.
Sorry no brilliant idea...
Best
Klaus
Re: app crashing
Posted: Tue Jan 14, 2014 5:10 pm
by Dixie
How are you playing your sounds ?
from the release notes...
To get a list of the sound channels that currently exist use:
iphoneSoundChannels()
This returns a return-delimited list of the channel names. Sound channels persist after any sounds have finished playing on them, retaining the last set volume setting. To remove a channel from memory completely use:
iphoneDeleteSoundChannel channel
Sound channels only consume system resources when they are playing sounds, thus you don't need to be concerned about having many around at once (assuming most are inactive!).
Re: app crashing
Posted: Tue Jan 14, 2014 6:19 pm
by teacherguy
Hi Dixie,
I am using:
Code: Select all
iphonePlaySoundOnChannel tSound ,1,"now"
iphonePlaySoundOnChannel tClick ,2,"now"
wait tQuarter milliseconds with messages
iphonePlaySoundOnChannel tSound ,1,"now"
wait threeQuarter milliseconds with messages
I have not been using the delete command… I will try adding that to the end of my handlers after my stop commands.
Re: app crashing
Posted: Tue Jan 14, 2014 7:15 pm
by teacherguy
Generally speaking… is it fair to say that using "lots" of globals for storing simple things (like point totals in a game) really don't consume any significant memory?
Re: app crashing
Posted: Tue Jan 14, 2014 8:42 pm
by jacque
A global will use as much memory as its content. If it contains just a numerical score, then it will be only a few bytes. If it contains a 10 meg file, then it will use 10 megs of RAM.
Re: app crashing
Posted: Wed Jan 15, 2014 5:50 pm
by teacherguy
Well, still not fixed. The app consistently crashes after about 15 minutes of play. Something is "building up" somewhere.
Re: app crashing
Posted: Wed Jan 15, 2014 7:53 pm
by jacque
Are there any clues in the system error log? Look in Console if you're on a Mac. I'm not sure where it is on Windows.
Re: app crashing
Posted: Thu Jan 16, 2014 3:45 am
by teacherguy
Thanks for the idea. It's an iPad app, so I played it until it crashed, then docked the iPad and looked at the log in xCode. Here is what it said (my app is Rhythm Reactor):
Incident Identifier: 01D7B59C-5FCB-4FC6-A896-D286714C7736
CrashReporter Key: 562418b825f136a8eaaa7dc959a5ac4f2694473e
Hardware Model: iPad2,1
OS Version: iPhone OS 7.0.4 (11B554a)
Kernel Version: Darwin Kernel Version 14.0.0: Fri Sep 27 23:00:48 PDT 2013; root:xnu-2423.3.12~1/RELEASE_ARM_S5L8940X
Date: 2014-01-15 20:39:58 -0600
Time since snapshot: 151 ms
Free pages: 1293
Active pages: 3605
Inactive pages: 1930
Speculative pages: 374
Throttled pages: 104618
Purgeable pages: 0
Wired pages: 17106
File-backed pages: 5518
Anonymous pages: 391
Compressions: 0
Decompressions: 0
Compressor Size: 0
Uncompressed Pages in Compressor: 0
Largest process: RhythmReactor
Processes
Name <UUID> rpages recent_max fds [reason] (state)
aosnotifyd <428390ccafe13fc0861a91f0469d70ce> 300 300 100 [vm-pageshortage] (daemon) (idle)
MobileSMS <339505ebbbc4301e87379b095a38ba13> 1459 1459 100 [vm-pageshortage] (background)
MobileMail <b3574f4bded1315cb2e50e5de205be48> 3684 3684 100 [vm-pageshortage] (continuous)
tccd <1fea8c5a71943151b5cd304c7eb0fd8c> 161 161 100 [vm-pageshortage] (daemon)
kbd <be2d64e41bf43e48a09a23fb129eb0b4> 434 434 100 [vm-pageshortage] (daemon)
RhythmReactor <85286eae787b32998bbd9d68f00917d5> 80048 80487 100 [vm-pageshortage] (frontmost) (resume)
identityservices <18cc20db2e4739a782cc8e38e03eff52> 406 406 100 (daemon)
wifid <a5cf99e5a0f032a69bc2f65050b44291> 355 355 25 (daemon)
powerd <0a253ac2a99236809422214be1700bc0> 125 125 50 (daemon)
syslogd <6539f4cf4dcf34daadf1d99991926680> 136 136 50 (daemon)
locationd <c31643022d833911b8b7461fd3964bd5> 616 616 100 (daemon)
imagent <bef102e1faef39209926fb25f428a71e> 393 393 100 (daemon)
mediaserverd <71101024312538ccae5799b88681e38d> 657 657 50 (daemon)
iaptransportd <42faa147f61a314bb735e239f445efaf> 210 210 50 (daemon)
mDNSResponder <8922e9954d893eb9a1ab27ca4723bbab> 193 193 50 (daemon)
apsd <0dd1fd7c2edc3cf9899a4830541c1bac> 418 418 100 (daemon)
dataaccessd <5da732b6ce6935f2928461a022101aba> 1182 1182 100 (daemon)
calaccessd <77a5672f2f653f64acf7367126a8d173> 213 213 100 (daemon)
SpringBoard <3c0e305139b331c6b37d2e9516f5804f> 5932 5932 50
backboardd <d61df126c4673b25bbfe5d9024be1d48> 5383 5383 50 (daemon)
fairplayd.A1 <3811115c65d43e8895faddf3f8ae7fd8> 127 127 50 (daemon)
lockdownd <6f28a28a0025348aa5361078e41914e3> 206 206 100 (daemon)
fseventsd <5c909a70b62f33c8856e3158834ba071> 180 180 100 (daemon)
configd <c57db43e53a73f8a9360f4d0d9001704> 403 403 100 (daemon)
aggregated <a5dda46586ba3a3cbb298bd8aa545e50> 480 480 50 (daemon)
BTServer <3933a8148924316b9f19dd3d10a23f00> 256 256 100 (daemon)
distnoted <38616bd8864034e7bc741f8bd7313349> 140 140 100 (daemon)
UserEventAgent <a3c7e56924ec3690a994a75a0ea79ee8> 536 536 50 (daemon)
networkd <84dfdb49c24132fa8dd10520deb16645> 403 403 100 (daemon)
filecoordination <4fa03f2b93363668a1159715de4b0270> 148 148 100 (daemon)
ubd <ca1400009326346db54f834cc8b740d2> 678 678 50 (daemon)
notifyd <35afacabfed73771889e72a017479709> 214 214 100 (daemon)
**End**
Re: app crashing
Posted: Thu Jan 16, 2014 3:58 am
by teacherguy
and this from the console....
========================
ASL is here to serve you
>
Jan 15 20:39:24 com.apple.launchd[1] <Notice>: (com.apple.accountsd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.
Jan 15 20:39:24 com.apple.launchd[1] <Error>: (com.apple.accountsd) assertion failed: 11B554a: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9
Jan 15 20:39:24 accountsd[623] <Error>: assertion failed: 11B554a: liblaunch.dylib + 19411 [7A8632AC-3E19-37EC-AFF1-672D2AD2A359]: 0x25
Jan 15 20:39:24 Unknown[623] <Error>:
Jan 15 20:39:24 aosnotifyd[620] <Notice>: 2014-01-15 20:39:24.300 aosnotifyd[620:4611]: The connection to ACDAccountStore was interrupted.
Jan 15 20:39:24 com.apple.launchd[1] <Notice>: (com.apple.accountsd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.
Jan 15 20:39:24 com.apple.launchd[1] <Error>: (com.apple.accountsd) assertion failed: 11B554a: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9
Jan 15 20:39:24 com.apple.launchd[1] <Notice>: (com.apple.lsd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.
Jan 15 20:39:24 com.apple.launchd[1] <Error>: (com.apple.lsd) assertion failed: 11B554a: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9
Jan 15 20:39:24 RhythmReactor[441] <Warning>: Received memory warning.
Jan 15 20:39:24 com.apple.launchd[1] <Notice>: (com.apple.lsd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.
Jan 15 20:39:24 com.apple.launchd[1] <Error>: (com.apple.lsd) assertion failed: 11B554a: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9
Jan 15 20:39:24 com.apple.launchd[1] <Notice>: (com.apple.lsd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.
Jan 15 20:39:24 com.apple.launchd[1] <Error>: (com.apple.lsd) assertion failed: 11B554a: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9
Jan 15 20:39:24 locationd[51] <Warning>: Launch Services: Registering unknown app identifier com.apple.locationd failed
Jan 15 20:39:24 RhythmReactor[441] <Warning>: Received memory warning.
Jan 15 20:39:24 com.apple.launchd[1] <Notice>: (com.apple.lsd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.
Jan 15 20:39:24 com.apple.launchd[1] <Error>: (com.apple.lsd) assertion failed: 11B554a: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9
Jan 15 20:39:24 com.apple.launchd[1] <Notice>: (com.apple.mobile.installd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.
Jan 15 20:39:24 com.apple.launchd[1] <Error>: (com.apple.mobile.installd) assertion failed: 11B554a: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9
Jan 15 20:39:24 locationd[51] <Warning>: Launch Services: Unable to find app identifier com.apple.locationd
Jan 15 20:39:24 com.apple.launchd[1] <Notice>: (com.apple.lsd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.
Jan 15 20:39:24 com.apple.launchd[1] <Error>: (com.apple.lsd) assertion failed: 11B554a: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9
Jan 15 20:39:24 com.apple.launchd[1] <Notice>: (com.apple.lsd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.
Jan 15 20:39:24 com.apple.launchd[1] <Error>: (com.apple.lsd) assertion failed: 11B554a: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9
Jan 15 20:39:34 RhythmReactor[441] <Warning>: Received memory warning.
Jan 15 20:39:33 com.apple.launchd[1] <Notice>: (com.apple.AOSNotification) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.
Jan 15 20:39:33 com.apple.launchd[1] <Error>: (com.apple.AOSNotification) assertion failed: 11B554a: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9
Jan 15 20:39:34 aosnotifyd[631] <Warning>: aosnotifyd has been launched
Jan 15 20:39:34 aosnotifyd[631] <Warning>: SpringBoard is already running. Continuing to start aosnotifyd
Jan 15 20:39:34 accountsd[632] <Error>: assertion failed: 11B554a: liblaunch.dylib + 19411 [7A8632AC-3E19-37EC-AFF1-672D2AD2A359]: 0x25
Jan 15 20:39:34 Unknown[632] <Error>:
Jan 15 20:39:34 com.apple.launchd[1] <Notice>: (com.apple.accountsd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.
Jan 15 20:39:34 com.apple.launchd[1] <Error>: (com.apple.accountsd) assertion failed: 11B554a: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9
Jan 15 20:39:34 accountsd[633] <Error>: assertion failed: 11B554a: liblaunch.dylib + 19411 [7A8632AC-3E19-37EC-AFF1-672D2AD2A359]: 0x25
Jan 15 20:39:34 Unknown[633] <Error>:
Jan 15 20:39:34 RhythmReactor[441] <Warning>: Received memory warning.
Re: app crashing
Posted: Thu Jan 16, 2014 5:58 pm
by teacherguy
Found this from Apple:
Good Practices Prevent Memory-Related Problems
There are two main kinds of problem that result from incorrect memory management:
Freeing or overwriting data that is still in use
This causes memory corruption, and typically results in your application crashing, or worse, corrupted user data.
Not freeing data that is no longer in use causes memory leaks
A memory leak is where allocated memory is not freed, even though it is never used again. Leaks cause your application to use ever-increasing amounts of memory, which in turn may result in poor system performance or your application being terminated.
------
So now I'm looking at every handler and making sure I am freeing up the variables. Not sure what else it could be.
Re: app crashing
Posted: Thu Jan 16, 2014 10:46 pm
by endernafi
Hi teacherguy,
Generally *memory leakages* are not a big concern when developing with LiveCode.
The engine is pretty smart about this
and takes almost every measure which the programmer is responsible when developing with Xcode.
My humble opinion is that your problem is not related to variables and their contents.
I think it's about the images you load during the game and the size of them.
I'm pretty sure that two suggestions below will solve your crashing problem.
Because only images and videos are the objects which are big enough in size to overfill the memory of the device.
iOS destroys an app if it uses more than approximately 50% of the physical memory.
So, I would try two things:
1. Downsize every each one of images, you used through your app, even their sizes are just at a level of kb's {21kb, 34kb, etc.}
For png's I suggest
tinyPng ; it's an excellent service.
For jpeg's try and find a service akin; since I don't use jpeg, I can't advise about them.
This method will also shrink the footprint of your game, thus it's a necessary step whether it solves your crashing problem or not.
2. If the former didn't solve your issue, then inspect every each one of your frames aka game moments.
You use *frame* aspect, right?
You should if you don't.
Don't create or *set the filename* an image which is unnecessary for that particular frame.
Delete or *empty the filename* of every image which are unnecessary for that particular frame.
EDIT:
Ok, I haven't read all posts, sorry for that.
It seems that you use a lot of sounds.
You should think about using smaller sound files {mp3's with a lower bitrate, maybe?} as a part of first suggestion.
And you also have to free your sound channels, as a part of second suggestion.
Sound files are big enough to fill the memory if they are used excessively.
Hope it helps...
Best,
~ Ender Nafi
Re: app crashing
Posted: Fri Jan 17, 2014 12:36 am
by teacherguy
Thank you Ender, I will have a look at my images. I too think this has something to do with the sounds, however, I have made sure to delete the sound channels after each round of the game, yet this crashing problem persists... always after about 15 minutes of play. There is clearly something I am missing.