Этот сайт имеет ограниченную функциональность, пока мы проводим техническое обслуживание для улучшения его работы. Если какая-либо статья не решила вашу проблему и вы хотите задать вопрос, наше сообщество поддержки ждёт вас: @FirefoxSupport в Твиттере и /r/firefox на Reddit.

Поиск в Поддержке

Избегайте мошенников, выдающих себя за службу поддержки. Мы никогда не попросим вас позвонить, отправить текстовое сообщение или поделиться личной информацией. Сообщайте о подозрительной активности, используя функцию «Пожаловаться».

Подробнее

why JS_AddValueRoot() leads to "losing efficacy" of GC

  • 2 ответа
  • 1 имеет эту проблему
  • 11 просмотров
  • Последний ответ от blueconch.hg

more options

Here's my js code:

     window.onload = function () {
       ...
       CarObject.addCallback("StringEvent", function(arg1, arg2){
         alert(arg2);
       });
       ...
     }

CarObject is a js variable, it maps to a C++ object internally, here I add a callback to the CarObject. as you see, the callback function is not a global function, so the callback function will be freed by GC. We use JS_AddValueRoot() which will add the callback function to GC's root set, this means the callback function(JSFunction *) will be protected from GC. but I found that it caught GC won't work, many object will be leaked when firefox exit.

Here's my js code: window.onload = function () { ... CarObject.addCallback("StringEvent", function(arg1, arg2){ alert(arg2); }); ... } CarObject is a js variable, it maps to a C++ object internally, here I add a callback to the CarObject. as you see, the callback function is not a global function, so the callback function will be freed by GC. We use JS_AddValueRoot() which will add the callback function to GC's root set, this means the callback function(JSFunction *) will be protected from GC. but I found that it caught GC won't work, many object will be leaked when firefox exit.

Все ответы (2)

more options

hello blueconch.hg, could you file a bug report for that issue at bugzilla.mozilla.org there it will get the attention of developers quicker! thank you...

more options

thanks philipp, I'm using source code of fennec21.0, I'm not sure whether it will occur on the lasted version. The problem(GC losing effective, there will be many leads when fennec exit.) may not be caught by JS_AddValueRoot(), maybe it's our code's problem. But I will try your suggestion, put it to https://bugzilla.mozilla.org/