如何管理A-Frame使用的内存? [英] How to mange memory used by A-Frame?

查看:80
本文介绍了如何管理A-Frame使用的内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个网络应用程序,该应用程序将360度图像加载到a-sky原语中。我正在使用 aframe-react a资产中总共有20多个360度图像,并且只有一个 img 资产。一旦用户切换场景,反应将更改资产 img src ,场景将重新呈现。一切正常,但由于缓存,因此占用了大量内存。一次它使用了4GB以上的内存。在移动设备中,切换约8张以上图片后,网页崩溃。我该如何处理这种情况?

I'm building a web app which has 360 degree images loaded into an a-sky primitive. I'm using aframe-react. There are total of 20+ 360 degree images and only one img asset inside a-assets. once user switches scene react will change src of asset img and scene will re render. Everything works fine but it's using lot of memory because of caching. One time it used 4GB+ memory. In mobile the web page crashes after switching through ~8+ images. How do I handle this situation?

我尝试查看THREE.Cache,但是图像没有在那里缓存。

I tried looking into THREE.Cache but images are not cached there.

此内存使用与使用React有关系吗?

Is this memory usage has anything to do with using React?

推荐答案

A-Frame有一个自动管理它的问题,但现在必须四处破解以清除纹理。

There's an issue for A-Frame to automatically manage it, but right now have to hack around to clear textures.

AFRAME.scenes[0].systems.material.textureCache[url].then(function (texture) {
  texture.dispose();    
});

这篇关于如何管理A-Frame使用的内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆