Skip to content

Instantly share code, notes, and snippets.

View sunbohong's full-sized avatar

酷酷的哀殿 sunbohong

View GitHub Profile
@sunbohong
sunbohong / .m
Created October 9, 2019 02:42
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);