I am using the scriptingBridge framework to communicate with Mail but I am getting massive leaks mainly from AEDescImpl (responsible library ScriptingBridge, responsible frame [SBObject initWithContext:specifier:] ) which I suspect are all the generated ScriptingBridge Objects. I got some others too anyway. How can I solved this? I enclosed the whole code into an @autoreleasepool block but I am still getting the same leaks.
In addition, my AppDelegate is an applescriptObjC class.
In brief, what the scripting bridge does is to get the messages selected in Mail (they come as a SBElementArray) and process them (get sub-objects for each message in the selection). In order to do this I use a for loop on the selection. If I select all messages in my mailbox (thousands), and even if the app only processes the first two of them (I tried to return the method after two iterations), I can see the real memory used from my app increasing by 30MB or so and this memory is not released in any way at the end of the method. Imagine repeating this a couple of times, the app can easily reach hundreds and hundreds MB of real memory used. Why? What am I doing wrong?
How are you measuring this leak? Your use of the term “real memory” suggest Activity Monitor, in which case I suggest you ignore it – it’s not telling you what you think it is. Profile it in Instruments instead, if you must.
My guess is you’ll find relatively minor leaks, and given they’re in code you have no control over, they’re not worth worrying about unless you’re writing an app that’s meant to run 24/7.
Sorry if I sound flippant, but life’s too short to worry about minor memory leaks in code you have no control over. If you can build a simple example and document accurately where it’s leaking, then you should log a bug report. But with bridged stuff they seem a fact of life, and OS memory management these days is such that they have to be serious to have much effect on the user.
The only other option is to have your app set to relaunch itself according to some schedule.
Sorry I can’t offer any specific help on eliminating the problem, but as I said, I suspect it’s in code you have no control over.