Skip to content

Instantly share code, notes, and snippets.

@sunbohong sunbohong/.m
Created Oct 9, 2019

Embed
What would you like to do?
Monitor memory warning
dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE,
0,
0x1|0x2|0x4|0x8|0x10|0x20|0xf0000000,
NULL);
dispatch_source_set_event_handler(source, ^{
dispatch_source_memorypressure_flags_t pressureLevel = dispatch_source_get_data(source);
NSLog(@"Received memory warning with pressure: %@", @(pressureLevel).description);
});
dispatch_resume(source);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.