简体   繁体   English

LIBGDX游戏内存泄漏

[英]LIBGDX Game Memory Leak

I'm developing a Game for Android with LibGDX. 我正在使用LibGDX开发Android游戏。 If i start my Game it work but i Debug the Memory Usage with this Methods 如果我开始我的游戏,它可以工作,但是我可以使用此方法调试内存使用情况

Gdx.app.log("Java Heap", String.valueOf(Gdx.app.getJavaHeap()));
Gdx.app.log("Native Heap", String.valueOf(Gdx.app.getNativeHeap()));

The Java Heap is constant but the Native Heap climb in the high. Java堆是不变的,但本机堆却在上升。 I do 15-20 actions on the screen with Textbutton, labels ect. 我使用Textbutton,label等在屏幕上执行15-20个动作。 and import .png files for the images. 并导入图像的.png文件。 I dipose this files with the dispose() Method but the Native Heap climb higher and i dont know what fill the Memory. 我用dispose()方法处理了这些文件,但是本机堆爬得更高了,我不知道什么填满了内存。

Now is my question give it a way to Debug what is in the Memory Usage or give it a way to clear all Native Heap out of dispose() ? 现在我的问题是给它一种调试内存使用情况的方法还是给它一个从dispose()中清除所有本机堆的方法? If anyone now a way to help please tell it. 如果有人现在可以提供帮助,请告诉它。

The way i try to optimize game using eclipse for android is through DDMS . 我尝试使用Eclipse为Android优化游戏的方式是通过DDMS There are two key tabs, HEAP and ALLOCATION TRACKER . 有两个关键选项卡, HEAPALLOCATION TRACKER Heap will let you know how much heap memory is consumed at that moment of time. Heap会让您知道在那一刻消耗了多少堆内存。 Allocation Tracker will keep track of memory allocation, as well as the class stack trace of who is allocating that memory. Allocation Tracker将跟踪内存分配,以及谁在分配该内存的类堆栈跟踪。

Also one golden rule, Never ever create new objects in render method. 这也是一条黄金法则, Never ever create new objects in render method.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM