这是一个可以添加到您的项目中的调试工具集合
#import "AppDelegate.h"
#import "MCMemoryWarningGenerators.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#ifdef DEBUG
// Force memory warnings to occur every 60 seconds. Helps you ensure you're
// handling them properly.
PERFORM_MEMORY_WARNING_AT_INTERVAL(60);
#endif
#ifdef DEBUG
// Allocate a block of memory every 30 seconds. Helps ensure your application
// can survive low memory conditions.
ALLOCATE_MEMORY_BLOCK_AT_INTERNAL(30);
#endif
return YES;
}
一个非常简单的工具,可以模拟应用程序中的低内存条件,以确保在收到内存警告时,它能够正确行为。
// generates a simulated memory warning continuously at the specified interval
// in seconds.
PERFORM_MEMORY_WARNING_AT_INTERVAL(interval);
// Allocates blocks of 5MB of memory continuously at the specified interval
// in seconds.
ALLOCATE_MEMORY_BLOCK_AT_INTERNAL(interval)
如果您在 CocoaPods
中使用,那就没有更简单的方法了。将以下内容添加到您的 Podfile
,并运行 pod install
。
pod 'MCDebuggingTools', :git => 'https://github.com/mirego/MCDebuggingTools.git'
不要忘记在需要的地方导入 #import "MCMemoryWarningGenerators.h"
。
MCDebuggingTools 是 © 2013 Mirego 并可以自由地在 新 BSD 许可证下分发。请参阅 LICENSE.md
文件。
Mirego 是一支热情洋溢的团队,我们相信工作是一个你可以创新和享受乐趣的地方。我们自豪地为 iPhone、iPad、Android、Blackberry、Windows Phone 和 Windows 8 开发了移动应用程序。在 life.mirego.com 上了解更多关于我们团队的信息。