flash as3 Texture IndexBuffer3D 泄漏

来源:互联网 发布:知到生态文明答案 编辑:程序博客网 时间:2024/05/01 22:52

texture如果upload之后不dispose,只是texture=null会有泄漏(内存、显存都有)


1.首先,根据API,texture最大上限是350M


2.个人PC测试数据:

代码:

private function render_2():void{var arr:Array = new Array();try {for (var i:int = 0; i < 21; ++i) {bitmapData = new BitmapData(2048, 2048);var tex:Texture = content.createTexture(2048, 2048, Context3DTextureFormat.BGRA, true);tex.uploadFromBitmapData(bitmapData);//bitmapData.dispose();bitmapData = null;weakDic[tex] = 1;arr.push(tex);}} catch (e:Error) {trace(e);trace(arr.length);fscommand("quit");}arr.length = 0;trace(getDicLen(weakDic));}public function main:void{render_2();}

(1)如果只是createTexture(...),而不upload,虽然不能超过上限,但是不会占用显存,

(2)只有upload之后,才会占用显存,而且还会占用内存(至于为什么占用内存,这个暂时不知道为什么。。望大神告知,O(∩_∩)O谢谢~

(3)上述代码测试中:创建了占用显存336M的texture,虽然是临时对象,但是显存实际上增加了226M,内存增加了200M,且一直存在,等了好久都没有降下去

(4)所以texture不dispose一定会有明显泄漏


再说IndexBuffer3D,与texture同样的测试,内存和显存居然都没有涨,但是不知道为什么,望大神告知~

0 0
原创粉丝点击