安卓内存泄漏?
您好,我有一个应用程序,一旦收到短信,它必须开始每 1 分钟收集一次用户的位置。一切开始正常,即如果我发送文本,则短信处理会唤醒并调用位置服务以开始每 1 分钟收集一次位置。但大约 30 分钟后,我的应用程序因内存问题而崩溃。我在DDMS中使用堆并观察到随着时间的推移内存不断增加,即数据对象的大小不断变大。我还使用分配跟踪器来查看我的代码中是否存在任何泄漏,并观察到在我的代码中创建的所有对象都被清除。我不确定我在哪里泄漏。请帮我理解这是内存泄漏吗?如果是的话,如何找到内存泄漏的位置?如果这不是内存泄漏,我怎样才能使应用程序无限运行直到我停止它。
Hi I have an application that once it recieves a sms, it has to start collecting the location of the user every 1 minute. Everything starts ok i.e. if I send a text, then the sms processing wakes up and calls the location service to start collecting the location every 1 minute. But after some 30 minutes or so, my application crashes because of memory. I used heap in DDMS and observed the memory which keeps on increasing as time goes i.e. the size of the data object keeps getting higher. I also used the allocation tracker to see if there is any leak in my code and observed all the objects are that being created in my code are getting cleared. I am not sure where I am leaking. Please help me understand is this a memory leak? If yes, how can I find where the memory leak is? IF this is not a memory leak, how can I make the application run infinitely until I stop it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看一下我最近发的一个帖子。我是发现内存泄漏的新手,这篇文章中的信息帮助我找到了所有内存泄漏并消除它们:
Android - 仅在具有 MapView 的单个 Activity 上出现许多 OutOfMemoryError 异常
Take a look at a post that I had recently. I was new to finding memory leaks and the info in this post helped me to find all of my memory leaks and squash them:
Android - Many OutOfMemoryError exceptions only on single Activity with MapView