I got one problem these days. I'm using an image-cache library, it works well but eventually i met memory issue and the app just quit itself (I guess it's because it just runs out of memory). After read the source code from the image-cache library, i found it's said that when there's memory warning event, it would release all images cached (the images are huge). Is there anyway for me to send Memory warning event to the device manually and directly ? I'm using xcode instrument tool to evaluate the memory usage.
To simulate the memory warning we need to enable the toggle when the app runs on the simulator. To enable the logger for memory warnings, please run the app onto the simulator and then go to Debug → Simulate Memory Warning.
onLowMemory() raises when the system global memory is low. If the global memory is okay but your process takes more than 24MB on old Android devices, it will crash and you'll never get a low memory warning.
You can manually simulate in the simulator:
Hardware -> Simulate Memory Warning
You can also simulate it programmatically:
- (void)simulateMemoryWarning
{
#if TARGET_IPHONE_SIMULATOR
#ifdef DEBUG
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), (CFStringRef)@"UISimulatedMemoryWarningNotification", NULL, NULL, true);
#endif
#endif
}
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), (CFStringRef)@"UISimulatedMemoryWarningNotification", NULL, NULL, true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With