Crashing on exception: NSImage: Insufficient memory to allocate pixel data buffer

On MacOS 10.13 we get this error on some Macs out of hundreds where the program is installed

Crashing on exception: NSImage: Insufficient memory to allocate pixel data buffer of 10741248 bytes
(10741248 or other)

And there is nothing in the crash log that tells me where to look, no method name from my “8Gestion” app

Application Specific Backtrace 1:
0 CoreFoundation 0x93a5f0e2 __raiseError + 178
1 libobjc.A.dylib 0xa6aaa346 objc_exception_throw + 273
2 CoreFoundation 0x93a5f005 +[NSException raise:format:] + 101
3 AppKit 0x9139f047 NSNewBitmapBackingStore + 229
4 AppKit 0x9152f653 -[NSBitmapImageRep _fromCGImage:performBlockUsingMutableData:] + 167
5 AppKit 0x9139ee2d __79-[NSBitmapImageRep _withoutChangingBackingPerformBlockUsingBackingMutableData:]_block_invoke + 205
6 AppKit 0x9139e8b5 -[NSBitmapImageRep _performBlockUsingBacking:] + 39
7 AppKit 0x9139ed59 -[NSBitmapImageRep _withoutChangingBackingPerformBlockUsingBackingMutableData:] + 85
8 AppKit 0x9139ece4 __57-[NSBitmapImageRep _performBlockUsingBackingMutableData:]_block_invoke + 104
9 AppKit 0x9139e8b5 -[NSBitmapImageRep _performBlockUsingBacking:] + 39
10 AppKit 0x9139ec75 -[NSBitmapImageRep _performBlockUsingBackingMutableData:] + 85
11 AppKit 0x9139ec19 -[NSBitmapImageRep getBitmapDataPlanes:] + 85
12 AppKit 0x9139eba9 -[NSBitmapImageRep bitmapData] + 47
13 AppKit 0x9149dedc -[NSBitmapGraphicsContext _initWithBitmapImageRep:] + 280
14 AppKit 0x9149ddad +[NSGraphicsContext graphicsContextWithBitmapImageRep:] + 71
15 AppKit 0x9149a5c5 +[_NSAutomaticFocusRing showForView:] + 2138
16 AppKit 0x914a7207 +[_NSAutomaticFocusRing updateIfNeeded] + 100
17 AppKit 0x91bf5845 -[NSView _oldDisplayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 186
18 AppKit 0x914a710f -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 119
19 AppKit 0x914a3698 -[NSView displayIfNeeded] + 1347
20 AppKit 0x914a30dc -[NSWindow displayIfNeeded] + 403
21 AppKit 0x91c25b43 ___NSWindowGetDisplayCycleObserver_block_invoke.5988 + 371
22 AppKit 0x914a292c __37+[NSDisplayCycle currentDisplayCycle]_block_invoke + 188
23 QuartzCore 0x9c810df5 _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 45
24 QuartzCore 0x9c80fa0c _ZN2CA11Transaction6commitEv + 184
25 AppKit 0x91c48577 __65+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayRefresh]_block_invoke + 465
26 CoreFoundation 0x93969066 _runLoopObserverWithBlockContext + 22
27 CoreFoundation 0x93968d76 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 22
28 CoreFoundation 0x93968c92 __CFRunLoopDoObservers + 498
29 CoreFoundation 0x9394c14d __CFRunLoopRun + 1661
30 CoreFoundation 0x9394b7a1 CFRunLoopRunSpecific + 641
31 CoreFoundation 0x9394b50a CFRunLoopRunInMode + 122
32 HIToolbox 0x92f4a42b RunCurrentEventLoopInMode + 321
33 HIToolbox 0x92f4a152 ReceiveNextEventCommon + 777
34 HIToolbox 0x92f49e2b _BlockUntilNextEventMatchingListInModeWithFilter + 71
35 AppKit 0x91371cc5 _DPSNextEvent + 2101
36 AppKit 0x91ae3c48 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2859
37 AppKit 0x91ae3115 -[NSApplication(NSEvent) nextEventMatchingMask:untilDate:inMode:dequeue:] + 134
38 XojoFramework 0x0451e1e6 ParseJSON + 13114
39 AppKit 0x91366c19 -[NSApplication run] + 763
40 XojoFramework 0x0468abba SSLSettings_SetValidateCertificates + 1051
41 XojoFramework 0x04688d94 RuntimeRun + 49
42 8Gestion 0x0016ca13 REALbasic._RuntimeRun + 34
43 8Gestion 0x03ce8ccc _Main + 295
44 8Gestion 0x03cb2c3d main + 36
45 8Gestion 0x03d4a0fe start + 53

Help :slight_smile:

a 32 bit run out of memory?

You could handle the exception.

How ? There is already an UnhandledException handler in the App objet, and it did not fire

You could use my Bug Reporter Kit
http://www.monkeybreadsoftware.de/xojo/Bugreporter/

or implement NSExceptionHandlerMBS yourself.

Ok I will try NSExceptionHandlerMBS, thanks

But… where to place it?

Each of my methods ends with “Exception” where I report the error and process what I can.
I have to replace all of them with this one:
Exception no NSExceptionMBS
and consider “n”?

Well, problem is that your app runs out of memory.
I don’t know why.

But NSExceptionHandlerMBS can maybe catch it, you can report it and app ends.

You can of course look for the memory leak and try to fix it.

Whoa! It looks like you may have found another bug with High Sierra as a quick glance at your report seems to suggest that it’s crashing when the view gets focus and it’s possibly attempting to update its internal cache.

And I’ll wager that it’s NOT failing on 10.12 or earlier Mac OS versions.

Like Sam says, there are serious issues in CoreGraphincs and teh video driver layer in 10.13.2.

The simplest solution to partially solve the problem of crashes is to check in the Informations of Finder the option “Open in low resolution” for my app: it is not beautiful, but the number of crashes decreases enormously …