Google Analytics(分析)发送匹配时的内存泄漏 [英] Memory Leak when Google Analytics sends a hit
问题描述
我正在尝试使用适用于iOS的Google Analytics(分析)SDK v3.10.
I'm trying to use Google Analytics SDK v3.10 for iOS.
我添加了所有依赖关系和标头,然后在我的应用程序委托中,方法:
I added all dependencies and headers, then in my app delegate, method :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
,我添加了这些行:
[[GAI sharedInstance] setDispatchInterval:20.0];
[[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXXXXXX-X"];
[[GAI sharedInstance].logger setLogLevel:kGAILogLevelVerbose];
具有正确的跟踪ID.
在登录视图的viewDidAppear方法中,我添加了行
In my landing view, method viewDidAppear, I added the lines
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName value:@"MyLandingView"];
[tracker send:[[GAIDictionaryBuilder createAppView] build]];
这会导致可怕的内存泄漏(大约+ 1mb/s)并冻结这些日志:
It leads to an horrible memory leak (about +1mb/s) and a freeze with those logs :
Apr 20 08:07:47 iPad-of-Pitt MyAppName[920] <Warning>: void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
这是一个已知的错误吗?关于如何避免这种情况的任何线索?
Is this a known bug ? Any clue on how to avoid that ?
提前谢谢!
在Google网上论坛 https://groups.google.com/forum/?fromgroups#!topic/ga-mobile-app-analytics/0goRZOc3vk0
EDIT : duplicated this question in google groups https://groups.google.com/forum/?fromgroups#!topic/ga-mobile-app-analytics/0goRZOc3vk0
也在 https://code.google.com/p/analytics-issues/issues/detail?id=617&thanks=617&ts=1429543879
推荐答案
我遇到了同样的问题.
I had the same issue.
在我的情况下,这是因为我使用Core Data和NSManagedObjectContextDidSaveNotification合并了来自后台进程的更新,导致出现异常,如
In my case that was because I use Core Data and NSManagedObjectContextDidSaveNotification to merge updates from a background process, resulting in a exception as described in this post :
我使用的解决方案是将ManagedObjectContext本身添加为NSNotificaition声明的对象:
The solution I used was to add the managedObjectContext itself as object of the NSNotificaition declaration :
ObjC
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(managedObjectContextDidSave:)
name:NSManagedObjectContextDidSaveNotification
object:self.managedObjectContext];
迅速
NSNotificationCenter.defaultCenter().addObserverForName(NSManagedObjectContextDidSaveNotification,
object: self.managedObjectContext,
queue: nil)
对我来说有用,没有更多的内存泄漏.
Did the trick for me, no more memory leak.
希望它会有所帮助.
这篇关于Google Analytics(分析)发送匹配时的内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!