hermes: Maybe Memory leaks caused by circular references

Problem

If I export an Image object in c++ to JavaScript to use, like the following

var image = new Image()

At this point, the image holds a C++ object, and the C++ object will not be released if the JS object is not GC. But if give the Image a callback, that callback holds the Image itself,like the following

var image = new Image(); image.on_load = function() { if (image.status) { ......... } }

In theory C++ will hold callbacks at this point, but the callback holds the image of the image, and the image object holds the C++ object, so the reference is cyclic.

Is there any good way to solve this memory problem automatically?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

So I think the JS engine should provide a mechanism to solve this kind of problem

@jpporto