Does a PhantomReference being in a ReferenceQueue stop the PhantomReference from being GC'd?

后端 未结 2 2069
半阙折子戏
半阙折子戏 2021-02-20 07:39

I\'m using the LWJGL libraries and unfortunately I need to free up texture/vbo buffers myself whenever a node in my scene graph needs to die, I can\'t even use finalize() method

2条回答
  •  日久生厌
    2021-02-20 08:04

    PhantomReference object is added to the queue when the referenced object id GC'd, not the PhantomReference itself. If you don't add a PhantomReference to a List, there is no reference to PhantomReference object, and thus it is GC'd immediately and never makes into the queue.

提交回复
热议问题