emscripten - 查看 Emscripten 编译的 JS 内存数组的内存使用情况
问题描述
在 Empscripten 编译的 JS 中,我是否可以调用一些 API 来告知内存数组中已用完的空间量以及仍然可用的空间量,以便我可以在生产应用程序中为该指标添加实时检测?
我的意思是“内存数组”,如:
"Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 402653184, (2) compile with -s ALLOW_MEMORY_GROWTH=1 which adjusts the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0
解决方案
您可以使用--memoryprofiler
和调整它来达到您的目标。
但更好的解决方案是编写自己的方法 - 这是描述所需的内容https://github.com/emscripten-core/emscripten/issues/8082#issuecomment-483963811
如果您对上述解决方案不感兴趣 - 只需-s ALLOW_MEMORY_GROWTH=1
按照您得到的错误建议使用(或者只是 prealloc 最大可能数量,即对于 Chrome 64 位 4GB,对于 Chrome 32 位 512 MB)。
推荐阅读
- python - 在 Dropbox Python API v2 中下载文件时遇到问题
- excel - 删除“联合”非连续范围
- api - 将 Canvas LMS API 调用中的 \N 替换为 NULL
- sql - SQL:连接两个时间序列数据并计算给定时间点的总数和比率
- c++ - 多级继承中的 CRTP derived() 方法
- javascript - 在节点js中将html表数据插入mysql数据库
- html - 仅 CSS 手风琴布局
- javascript - Javascript 为什么标头脚本中的对象属性可以,但在 html 中未定义?
- react-native - 如何在 Connect 组件下的 graphql 查询中使用 $filter 变量?
- r - 根据唯一值有条件地将字符串更改为因子?