te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - Three js memory management - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Three js memory management - Stack Overflow

programmeradmin3浏览0评论

I have a large scene with a lot of Mesh and MorphAnimMesh. I want to free memory when the meshes are removed. If i know right this is the best way to do:

for ( var i = scene.children.length - 1; i >= 0 ; i -- ) {
  var obj = scene.children[i];
  scene.remove(obj);
  obj.deallocate(); 
  obj.geometry.deallocate();
  obj.material.deallocate();
  obj.material.map.deallocate();
}

if i check the memory usage at task manager after this, nothing changes. ( tried to wait a few min for GC but nothing. ) Google Chrome memory snapshot shows the objects still there. morphTargets in THREE.Geometry @1862203 etc.

Tried to set the obj to null, but still no memory decrease.

Any idea what am i doing wrong?

Its a game with levels and the player can change from one to another. After a few change memory usage increases to really high. Thats why i want to remove all object from memory before the level change.

I have a large scene with a lot of Mesh and MorphAnimMesh. I want to free memory when the meshes are removed. If i know right this is the best way to do:

for ( var i = scene.children.length - 1; i >= 0 ; i -- ) {
  var obj = scene.children[i];
  scene.remove(obj);
  obj.deallocate(); 
  obj.geometry.deallocate();
  obj.material.deallocate();
  obj.material.map.deallocate();
}

if i check the memory usage at task manager after this, nothing changes. ( tried to wait a few min for GC but nothing. ) Google Chrome memory snapshot shows the objects still there. morphTargets in THREE.Geometry @1862203 etc.

Tried to set the obj to null, but still no memory decrease.

Any idea what am i doing wrong?

Its a game with levels and the player can change from one to another. After a few change memory usage increases to really high. Thats why i want to remove all object from memory before the level change.

Share Improve this question asked Dec 17, 2012 at 13:18 user974250user974250 2471 gold badge3 silver badges9 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 10

Most likely, you need to add some, or all, of the following:

geometry.dispose();
material.dispose();
texture.dispose();

Check out these examples:

http://mrdoob.github./three.js/examples/webgl_test_memory.html

http://mrdoob.github./three.js/examples/webgl_test_memory2.html

three.js r.60

I did try all the dispose and deallocate methods but nothing worked.

Then I did the following for my ionic application which is using webgl renderer to render a 360 image.

this.renderer = new THREE.WebGLRenderer({ antialias: true });
RicohView.prototype.stopRendering = function () {
    this.canRender = false;
    this.renderer.forceContextLoss();
    this.renderer.dispose();
    console.log('renderer disposed');
    cancelAnimationFrame(this.requestId);
}

requestId is something which can be captured from

this.requestId = requestAnimationFrame(render);
发布评论

评论列表(0)

  1. 暂无评论