away3d 4.0 Error #3691: 超出此資源類型的資源限制。


  away3d的每個版本差異都特別大,之前使用3.6做了一個東西,在要交工時才發現render方法有內存泄漏,無耐之下又要用4.0重新做一遍,這一做就又是三天,真是差異太大了。

  今天遇到一個很奇怪的問題: Error #3691: 超出此資源類型的資源限制。錯誤定位在 view.rendre()方法。以該錯誤的英文error #3691 resource limit for this resource type exceeded 在google中搜索(百度在這方面簡直是垃圾!),有效解釋如下:

   “Which means that you are exceeding the texture resource limits in the Flash Player / Stage3D;” 
  Limits are described here:http://help.adobe.com/en_US/FlashPla...Context3D.html   

Resource Number allowed Total memory
Vertex buffers 4096 256 MB
Index buffers 4096 128 MB
Programs 4096 16 MB
Textures 4096 128 MB¹
Cube textures 4096 256 MB

 

 

 

 

 

  又找到這樣的解釋:

  “It seems the actual geometry of the Plane is never disposed, which prevents the buffers from being cleaned up”. 

     ( 看起來像是實際的geometry沒有銷毀,仍然占用着緩存區。)

    聯想到我的應用,是反復執行刪除mesh,添加mesh的操作,刪除的代碼如下:  

/*清空scene中的內容*/
private function clearScene():void
{    
   while(this.tileGroup.numChildren>0)
  {
    var t:TileMesh=tileGroup.getChildAt(0) as TileMesh;  
    tileGroup.removeChild(t);
    t.dispose();  //此處是對mesh的銷毀,難道是沒有真正銷毀?
    t=null;
  }
}

TileMesh是我繼承自Mesh類實現的一個自己的mesh類,在從場景中刪除時也執行了t.dispose() 這個銷毀操作,有沒有可能是這個銷毀操作沒有刪除Mesh的Geometry呢?

 

修改代碼如下:

/*清空scene中的內容*/
private function clearScene():void
{    
   while(this.tileGroup.numChildren>0)
  {
    var t:TileMesh=tileGroup.getChildAt(0) as TileMesh;  
    tileGroup.removeChild(t);
    t.distroy();  //distroy是TileMesh中自己實現的一個方法,用於銷毀geometry 和 material
    t=null;
  }
}
distroy是TileMesh中自己實現的一個方法,用於銷毀geometry 和 material,代碼如下:
public function distroy():void
{
    this.geometry.dispose();
    this.material.dispose();
}

再次執行程序,運行正常,沒有再出現之前的錯誤“ Error #3691: 超出此資源類型的資源限制”。

 
       


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM