class func availableMemory() -> size_t {
return os_proc_available_memory()
}
Cannot find 'os_proc_available_memory' in scope
Is there a version I can access from Swift?
Post
Replies
Boosts
Views
Activity
memoryFootprint is quite confusing code but useful.
Putting it in the debugger and studying info (at line return info.phys_footprint) I see it has a field limit_bytes_remaining
Is this a useful guideline as to how much memory is available for allocation?
I notice that when UIGraphicsBeginImageContextWithOptions(size,....) fails with a message "Cannot allocate X bytes" X is 16 x size.width x size.height
I would like to know if UIGraphicsBeginImageContextWithOptions will fail before I call it and crash
This is ongoing.
I simplified the code to:
import UIKit
func SaveImageAsPhoto(image:UIImage) {
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
}
and I get the same results. At best it works half the time.
Do I need to use a semephore to serialise the callback? If I call UIImageWriteToSavedPhotosAlbum twice without waiting for the callback to complete will the second call fail silently?
I found this:
#define MACH_TASK_BASIC_INFO 20 /* always 64-bit basic info */
struct mach_task_basic_info {
mach_vm_size_t virtual_size; /* virtual memory size (bytes) */
mach_vm_size_t resident_size; /* resident memory size (bytes) */
mach_vm_size_t resident_size_max; /* maximum resident memory size (bytes) */
time_value_t user_time; /* total user run time for
* terminated threads */
time_value_t system_time; /* total system run time for
* terminated threads */
policy_t policy; /* default policy for new threads */
integer_t suspend_count; /* suspend count for task */
};
This is in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer//SDKs/MacOSX.sdk/usr/include/mach/task_info.h
I need an answer to this too.
I found this by searching for "AddressSanitizer: allocator is out of memory trying to allocate"
I have turned on Address Sanitizer. I know I am having memory problems. I want to find where
My problem is there is what looks like a stack trace output, but it is not including any code I wrote. Where can I get a useful stack trace? How can I profile allocations to find the offending allocation?
2021-08-12 09:12:07.313295+1200 B52FloorManagement[526:176200] #0 0x1082f4db4 in __sanitizer_mz_calloc+0x8c (/private/var/containers/Bundle/Application/31C1D5A3-40AB-4C5D-8B1B-6E3D2692BFEF/B52FloorManagement.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib:arm64e+0x40db4)
2021-08-12 09:12:07.313351+1200 B52FloorManagement[526:176200] #1 0x1a14aba9c in <redacted>+0x54 (/usr/lib/system/libsystem_malloc.dylib:arm64e+0x12a9c)
2021-08-12 09:12:07.313398+1200 B52FloorManagement[526:176200] #2 0x1938f9fe4 in <redacted>+0xf8 (/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics:arm64e+0x1e7fe4)
2021-08-12 09:12:07.313442+1200 B52FloorManagement[526:176200] #3 0x1938f8eec in <redacted>+0x1cec (/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics:arm64e+0x1e6eec)
2021-08-12 09:12:07.313489+1200 B52FloorManagement[526:176200] #4 0x1938f5720 in <redacted>+0x424 (/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics:arm64e+0x1e3720)
2021-08-12 09:12:07.313532+1200 B52FloorManagement[526:176200] #5 0x1937142b8 in <redacted>+0x2c8 (/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics:arm64e+0x22b8)
2021-08-12 09:12:07.313607+1200 B52FloorManagement[526:176200] #6 0x193916258 in <redacted>+0x47c (/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics:arm64e+0x204258)
2021-08-12 09:12:07.313873+1200 B52FloorManagement[526:176200] #7 0x193980e24 in <redacted>+0x2d8 (/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics:arm64e+0x26ee24)
2021-08-12 09:12:07.314147+1200 B52FloorManagement[526:176200] #8 0x1938b23c8 in CGDisplayListDrawInContextDelegate+0x1c4 (/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics:arm64e+0x1a03c8)
2021-08-12 09:12:07.314393+1200 B52FloorManagement[526:176200] #9 0x19374b86c in <redacted>+0x704 (/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics:arm64e+0x3986c)
2021-08-12 09:12:07.314634+1200 B52FloorManagement[526:176200] #10 0x19374b130 in <redacted>+0x34 (/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics:arm64e+0x39130)
2021-08-12 09:12:07.314837+1200 B52FloorManagement[526:176200] #11 0x19441ae18 in <redacted>+0x24 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64e+0x76fe18)
2021-08-12 09:12:07.314985+1200 B52FloorManagement[526:176200] #12 0x19441b8cc in <redacted>+0x24 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64e+0x7708cc)
2021-08-12 09:12:07.315161+1200 B52FloorManagement[526:176200] #13 0x19441e2d4 in <redacted>+0x1d0 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64e+0x7732d4)
2021-08-12 09:12:07.315403+1200 B52FloorManagement[526:176200] #14 0x19441e0cc in <redacted>+0x78 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64e+0x7730cc)
2021-08-12 09:12:07.315536+1200 B52FloorManagement[526:176200] #15 0x19441b80c in <redacted>+0xc0 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64e+0x77080c)
2021-08-12 09:12:07.315679+1200 B52FloorManagement[526:176200] #16 0x105ffee80 in $s18B52FloorManagement24createQCIScreenShotImageSo7UIImageCyF+0x938 (/private/var/containers/Bundle/Application/31C1D5A3-40AB-4C5D-8B1B-6E3D2692BFEF/B52FloorManagement.app/B52FloorManagement:arm64+0x1010e2e80)
2021-08-12 09:12:07.315855+1200 B52FloorManagement[526:176200] #17 0x105a41be4 in $s18B52FloorManagement18DialogMainMoreMenuV17createLayoutImageyyF13_layoutImagesL_yyF+0x1264 (/private/var/containers/Bundle/Application/31C1D5A3-40AB-4C5D-8B1B-6E3D2692BFEF/B52FloorManagement.app/B52FloorManagement:arm64+0x100b25be4)
2021-08-12 09:12:07.316102+1200 B52FloorManagement[526:176200] #18 0x105ecb9b4 in $s18B52FloorManagement11CoordinatorC4draw2inySo7MTKViewC_tF+0x598 (/private/var/containers/Bundle/Application/31C1D5A3-40AB-4C5D-8B1B-6E3D2692BFEF/B52FloorManagement.app/B52FloorManagement:arm64+0x100faf9b4)
2021-08-12 09:12:07.316304+1200 B52FloorManagement[526:176200] #19 0x105ecc364 in $s18B52FloorManagement11CoordinatorC4draw2inySo7MTKViewC_tFTo+0x84 (/private/var/containers/Bundle/Application/31C1D5A3-40AB-4C5D-8B1B-6E3D2692BFEF/B52FloorManagement.app/B52FloorManagement:arm64+0x100fb0364)
2021-08-12 09:12:07.316433+1200 B52FloorManagement[526:176200] #20 0x1c474779c in <redacted>+0xb4 (/System/Library/Frameworks/MetalKit.framework/MetalKit:arm64e+0x1379c)
2021-08-12 09:12:07.316637+1200 B52FloorManagement[526:176200] #21 0x1c4743d10 in <redacted>+0x24 (/System/Library/Frameworks/MetalKit.framework/MetalKit:arm64e+0xfd10)
2021-08-12 09:12:07.316826+1200 B52FloorManagement[526:176200] #22 0x10967fd6c in -[DYDisplayLinkInterposer forwardDisplayLinkCallback:]+0xa8 (/Developer/Library/PrivateFrameworks/GPUToolsCore.framework/GPUToolsCore:arm64e+0x13d6c)
2021-08-12 09:12:07.316964+1200 B52FloorManagement[526:176200] #23 0x1950ea7b4 in <redacted>+0x29c (/System/Library/Frameworks/QuartzCore.framework/QuartzCore:arm64e+0x147b4)
2021-08-12 09:12:07.317103+1200 B52FloorManagement[526:176200] #24 0x1951c97f0 in <redacted>+0x114 (/System/Library/Frameworks/QuartzCore.framework/QuartzCore:arm64e+0xf37f0)
2021-08-12 09:12:07.317252+1200 B52FloorManagement[526:176200] #25 0x191ddca58 in <redacted>+0xac (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64e+0x7ea58)
2021-08-12 09:12:07.317406+1200 B52FloorManagement[526:176200] #26 0x191e02270 in <redacted>+0x38 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64e+0xa4270)
2021-08-12 09:12:07.317549+1200 B52FloorManagement[526:176200] #27 0x191e015f0 in <redacted>+0x250 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64e+0xa35f0)
2021-08-12 09:12:07.317747+1200 B52FloorManagement[526:176200] #28 0x191dfb1d4 in <redacted>+0x940 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64e+0x9d1d4)
2021-08-12 09:12:07.317903+1200 B52FloorManagement[526:176200] #29 0x191dfa35c in CFRunLoopRunSpecific+0x254 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64e+0x9c35c)
2021-08-12 09:12:07.318266+1200 B52FloorManagement[526:176200]
Turns out that some mysteruious bg in Big Sur had a old version of Xcode running on my machinde. After a few reboots and I really do not know what xcode is up to date again and it is all working
This is a unreliable software eco system. Get used to it. Mostly works
ls /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
10.0 10.2 11.0 11.2 11.4 12.1 12.3 13.0 13.2 13.4 13.6 14.0 14.2 14.4 9.0 9.2
10.1 10.3 11.1 11.3 12.0 12.2 12.4 13.1 13.3 13.5 13.7 14.1 14.3 14.5 9.1 9.3
Where is 14.6?