Skip to content

App Memory Leaks

March 19, 2014

The other day I had to shutdown the Macbook Pro I was using and reboot.  I really wondered what the heck was going on – I mean, this is a Mac.  I then decided to mess with the synth app and starting looking at the memory monitor.  The memory usage grew and grew, and then the old friend ‘memory leak’ came to mind.  As it turns out, my app’s memory footprint would grow and grow based on some old, novice class retain statements I thought I needed at the time (this was 2011).  Sure, the app worked, but it was far from efficient.  

It comes down to this:  I did not quite have a good understanding of retain/init and release/retain.  As it turns out, I am far better off leaving a class instance in memory than trying to init and release it.  You see, in the case of this app, where I have made custom effects and filters, class instances get called in microsecond intervals.  Each time a class is called, a new set of variables (and small buffering arrays) would pop into memory.  Sure, separate instances are needed for various modules within the synth calling on, let’s say the LFO engine, but this LFO engine does not need multiple instances brought up during a “saw” oscillator “run-through”….  In any event, I started correcting things and the memory allocation seems to have stabled out at about 21MB.  The Instruments application, a part of Xcode, was extremely useful.  All done over lunch.




From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: