Memory management differences Sierra/High Sierra

Is there any difference between Sierra and High Sierra regarding memory management of apps? I’m getting crash logs every couple of days all similar and related to memory:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.QuartzCore 0x9c8220b9 magazine_dealloc_ + 260
1 com.apple.QuartzCore 0x9c822345 x_mem_dealloc_bucket + 128
2 com.apple.QuartzCore 0x9c842bfb CA::timer_callback(__CFRunLoopTimer*, void*) + 183
3 com.apple.CoreFoundation 0x939169d3 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 19
4 com.apple.CoreFoundation 0x93916548 __CFRunLoopDoTimer + 1224
5 com.apple.CoreFoundation 0x93915fbb __CFRunLoopDoTimers + 395
6 com.apple.CoreFoundation 0x9390dbfb __CFRunLoopRun + 3211
7 com.apple.CoreFoundation 0x9390cc41 CFRunLoopRunSpecific + 641
8 com.apple.CoreFoundation 0x9390c9aa CFRunLoopRunInMode + 122
9 com.apple.HIToolbox 0x92f0dd3b RunCurrentEventLoopInMode + 321
10 com.apple.HIToolbox 0x92f0da62 ReceiveNextEventCommon + 777
11 com.apple.HIToolbox 0x92f0d73b _BlockUntilNextEventMatchingListInModeWithFilter + 71
12 com.apple.AppKit 0x9136538d _DPSNextEvent + 2101
13 com.apple.AppKit 0x91ad6c74 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2859
14 com.apple.AppKit 0x91ad6141 -[NSApplication(NSEvent) nextEventMatchingMask:untilDate:inMode:dequeue:] + 134
15 com.xojo.XojoFramework 0x023a0c7b 0x235f000 + 269435
16 com.xojo.XojoFramework 0x023a0cc4 0x235f000 + 269508
17 com.mothsoftware.mailarchiverx 0x001fd793 Delegate.Invoke%% + 34
18 com.mothsoftware.mailarchiverx 0x0009c8fb Application._CallFunctionWithExceptionHandling%%op + 248
19 com.xojo.XojoFramework 0x0250dd4a 0x235f000 + 1764682
20 com.xojo.XojoFramework 0x023a0c1c 0x235f000 + 269340
21 com.apple.AppKit 0x9135a2e1 -[NSApplication run] + 763
22 com.xojo.XojoFramework 0x0250ddea 0x235f000 + 1764842
23 com.xojo.XojoFramework 0x0250bfc4 RuntimeRun + 49
24 com.mothsoftware.mailarchiverx 0x001afef0 REALbasic._RuntimeRun + 34
25 com.mothsoftware.mailarchiverx 0x0198ac8e _Main + 295
26 com.mothsoftware.mailarchiverx 0x01984dd8 main + 36
27 com.mothsoftware.mailarchiverx 0x01a4b77d start + 53

or

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.QuartzCore 0x9c8221e3 free_magazine + 34
1 com.apple.QuartzCore 0x9c822281 collect_depot + 114
2 com.apple.QuartzCore 0x9c822123 magazine_dealloc_ + 366
3 com.apple.QuartzCore 0x9c822345 x_mem_dealloc_bucket + 128
4 com.apple.QuartzCore 0x9c842bfb CA::timer_callback(__CFRunLoopTimer*, void*) + 183
5 com.apple.CoreFoundation 0x939169d3 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 19
6 com.apple.CoreFoundation 0x93916548 __CFRunLoopDoTimer + 1224
7 com.apple.CoreFoundation 0x93915fbb __CFRunLoopDoTimers + 395
8 com.apple.CoreFoundation 0x9390dbfb __CFRunLoopRun + 3211
9 com.apple.CoreFoundation 0x9390cc41 CFRunLoopRunSpecific + 641
10 com.apple.CoreFoundation 0x9390c9aa CFRunLoopRunInMode + 122
11 com.apple.HIToolbox 0x92f0dd3b RunCurrentEventLoopInMode + 321
12 com.apple.HIToolbox 0x92f0da62 ReceiveNextEventCommon + 777
13 com.apple.HIToolbox 0x92f0d73b _BlockUntilNextEventMatchingListInModeWithFilter + 71
14 com.apple.AppKit 0x9136538d _DPSNextEvent + 2101
15 com.apple.AppKit 0x91ad6c74 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2859
16 com.apple.AppKit 0x91ad6141 -[NSApplication(NSEvent) nextEventMatchingMask:untilDate:inMode:dequeue:] + 134
17 com.xojo.XojoFramework 0x023bac7b 0x2379000 + 269435
18 com.xojo.XojoFramework 0x023bacc4 0x2379000 + 269508
19 com.mothsoftware.mailarchiverx 0x001ebd69 Delegate.Invoke%% + 34
20 com.mothsoftware.mailarchiverx 0x0008f0d2 Application._CallFunctionWithExceptionHandling%%op + 248
21 com.xojo.XojoFramework 0x02527d4a 0x2379000 + 1764682
22 com.xojo.XojoFramework 0x023bac1c 0x2379000 + 269340
23 com.apple.AppKit 0x9135a2e1 -[NSApplication run] + 763
24 com.xojo.XojoFramework 0x02527dea 0x2379000 + 1764842
25 com.xojo.XojoFramework 0x02525fc4 RuntimeRun + 49
26 com.mothsoftware.mailarchiverx 0x001a4074 REALbasic._RuntimeRun + 34
27 com.mothsoftware.mailarchiverx 0x019dd8ee _Main + 295
28 com.mothsoftware.mailarchiverx 0x019d7bcb main + 36
29 com.mothsoftware.mailarchiverx 0x01a967d1 start + 53

I don’t remember getting this type of crash that often with Sierra. The only other difference is the Xojo version. Does anyone have an idea what might cause these crashes? I’m still on 32bit and 64bit is next on my agenda.

What is the actual error? The above is only the call stack.

Is this a background running app?

I suspect the timer is not getting any time, after a callback is being called (Xojo.Core.Time.CallLater ?)
Maybe appnap, or something else is disturbing the process?

@Eli:

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x000000000ccbed78
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]

VM Regions Near 0xccbed78:
VM_ALLOCATE 000000000ccbd000-000000000ccbe000 [ 4K] r–/r-- SM=PRV
–>
VM_ALLOCATE 000000000ccbf000-000000000ccc0000 [ 4K] rw-/rwx SM=PRV

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.QuartzCore 0x9c8221e3 free_magazine + 34
1 com.apple.QuartzCore 0x9c822281 collect_depot + 114

and

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000181ff2f0
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]

VM Regions Near 0x181ff2f0:
VM_ALLOCATE 00000000181fe000-00000000181ff000 [ 4K] rw-/rwx SM=PRV
–>
WebKit Malloc 0000000018200000-0000000018700000 [ 5120K] rw-/rwx SM=PRV

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.QuartzCore 0x9c8220b9 magazine_dealloc_ + 260

Both users were adding data to the database during the crash.

@Derk Jochems: the app isn’t running in the background. I have the usual mishmash of worker thread and progress window which uses CallDelegateOnMainThreadMBS and other direct functions of the MBS plugin. AppNap is disabled. The only timer that runs constantly is an update check that runs every hour.

Does this happen when the application is in front or for example when it is minimized or hidden?

@Eli Ott: good question. I’ll ask the users.

What does this mean for Xojo apps:

https://stackoverflow.com/questions/17969493/cfrunloop-is-calling-out-to-an-observer-callback-function-18-23-corefoundati

[code]This crash occurs when using NSNotificationCenter

You registered a notification observer to an object that has been released and didn’t removed the observer. So when it tries to call the selector it crashes.

If you are using a ViewController of some kind, you can add

[[NSNotificationCenter defaultCenter] removeObserver:self name:@“Notification” object:nil];
to the viewWillDisappear

if it is not a ViewController you can use -(void) dealloc to unregister the Observer.[/code]

That’s like if you use AddHandlee to call a method, which in turn updates a control on a window, but then the Window closes and you don’t call RemoveHandler. The method stays around because of the AddHandler, but the things it changes do not. When the method gets called, you get a NilObjectException because the control instances are Nil.

[quote=358869:@Beatrix Willius]What does this mean for Xojo apps:

https://stackoverflow.com/questions/17969493/cfrunloop-is-calling-out-to-an-observer-callback-function-18-23-corefoundati [/quote]
Nothing as far as I know (unless you use NSNotificationCenter through declares or plugins). I’m not totally sure though.

CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION is an internal function of Core Foundation. It does what its name says. CFRunLoop is the main dispatch function of a macOS desktop app. When necessary timers are called and then timers call their registered callback function. And one of these is Nil.

@Eli Ott and Greg O’Lone: thanks for the explanations. I’m using NSNotificationCenter through the MBS plugin but this isn’t called when data is added. The only timer I have is the update checker. Might CallDelegateOnMainThreadMBS be using a timer internally?

If I had been doing something really stupid this would crash every time. But so far I haven’t seen crashes like these myself. I only manage to crash Xojo often :slight_smile:

I’m pretty sure Christian does use a timer for this class of functions as it is about the only way you can make code run on the main thread.

[quote=358841:@Beatrix Willius]0 com.apple.QuartzCore 0x9c8220b9 magazine_dealloc_ + 260
1 com.apple.QuartzCore 0x9c822345 x_mem_dealloc_bucket + 128
2 com.apple.QuartzCore 0x9c842bfb CA::timer_callback(__CFRunLoopTimer*, void*) + 183[/quote]
This looks like a CoreAnimation issue, where something it’s trying to release has already been released.

First thing I’d do is to disable all my code to use the NSNotificationCenter, if the crashes stop, then it’s a good indication that it’s there and at that point talk with Christian, so he can check and see how he’s handling the observer in his plugin.