简体   繁体   English

在libgdx中渲染时出现OutOfMemoryError

[英]OutOfMemoryError while rendering in libgdx

I have to render mesh array in using libgdx in render(). 我必须在render()中使用libgdx渲染网格数组。 I used handler because every time I'm getting new data in getMeshToRender() method in meshArr array. 我之所以使用处理程序,是因为每次我都在meshArr数组的getMeshToRender()方法中获取新数据时。

        onCreate()
        {
          handler.removeCallbacks(sendUpdatesToUI);  
          handler.postDelayed(sendUpdatesToUI, 1000); // 1 second
        }

        Runnable sendUpdatesToUI = new Runnable() 
     {
            public void run() 
            {
                //DisplayLoggingInfo();   
                getMeshToRender();
                handler.postDelayed(this, 1000); // 1 seconds
            }
        };          

   getMeshToRender()

 {

   .......
    meshArr = new Mesh[numMesh];
   .......
 }

in Render() method it initially loads that meshArr but then crashes with OutOfMemoryError. 在Render()方法中,它最初加载该meshArr,但随后由于OutOfMemoryError崩溃。

Any solution will be aprreciable. 任何解决方案都是可行的。 Thanks 谢谢

The simple, and only real, answer is to use less memory. 简单且唯一可行的答案是使用更少的内存。

Either you are just using too many different meshes, and you should rethink your whole idea, or you are replacing them and not properly disposing of the old ones. 您可能只是使用了太多不同的网格,而您应该重新考虑整个想法,或者您正在替换它们而不适当地处置旧的网格。

If you want to release unused meshes, you should use Mesh#dispose() 如果要释放未使用的网格,则应使用Mesh#dispose()

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

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