Javascript force GC collection? / Forcefully free object?

后端 未结 3 491
不知归路
不知归路 2020-12-14 01:29

I have a js function for playing any given sound using the Audio interface (creating a new instance for every call).

This works quite well, until about the 32nd call

3条回答
  •  -上瘾入骨i
    2020-12-14 02:27

    This is not an exhaustive answer, but to the question "Is there any way to force the chrome js engine to do garbage collection?", a chromium.org guy replied:

    In general, no, by design. For testing purposes there is a flag you can pass on the command line to enable a javascript command "window.gc()" to force garbage collection.

    --js-flags '--expose_gc'


    UPDATE: However, as @plash noted in a comment below, this flag will only work in debug builds.

提交回复
热议问题