Monday, December 11, 2017

#1 2015-12-10 11:44:28 am

Pier
Member
Registered: 2014-06-23
Posts: 16

Memory leaks and scripting bridge

Hey guys,

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.

Thank you in advance.

Pier

Last edited by Pier (2015-12-10 01:50:07 pm)

Offline

 

#2 2015-12-10 06:05:35 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5197

Re: Memory leaks and scripting bridge

I'm assuming you've checked that ARC is on.

Can you quantify "massive" in some way? Last I looked there were some leaks, but not enough to lose sleep over.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2015-12-10 07:53:50 pm

Pier
Member
Registered: 2014-06-23
Posts: 16

Re: Memory leaks and scripting bridge

Shane Stanley wrote:

I'm assuming you've checked that ARC is on.

Can you quantify "massive" in some way? Last I looked there were some leaks, but not enough to lose sleep over.


Yes ARC is on.

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?

Thanks.

Pier

Offline

 

#4 2015-12-10 08:06:01 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5197

Re: Memory leaks and scripting bridge

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.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#5 2015-12-10 08:19:33 pm

Pier
Member
Registered: 2014-06-23
Posts: 16

Re: Memory leaks and scripting bridge

Shane Stanley wrote:

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.


Yes, the leaks I find in instruments are minor and unfortunately, yes the app is supposed to run 24/7. What is the approach in this case?

Pier

Offline

 

#6 2015-12-10 08:35:13 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5197

Re: Memory leaks and scripting bridge

Pier wrote:

Yes, the leaks I find in instruments are minor and unfortunately, yes the app is supposed to run 24/7. What is the approach in this case?


Live with it.

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.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)