What are weak global links? How is it different from a global link?

What are the weak global references in JNI? How is it different from a global link and local link?

+6
source share
2 answers

I think the answer to your questions can be found here: http://java.sun.com/docs/books/jni/html/refs.html

As written:

Local and global links have different lifetimes. Local links are automatically freed, while global and weak global links remain valid until they are freed by the programmer.

Difference Between Local Links and Global Links: Context

A local reference is a local variable. The main object will be destroyed after you exit its context (for example, return from the built-in function that defined it).

Like global references, weak global references remain valid calls of own methods and different flows. Unlike global links, weak global links do not save the underlying object from garbage collection.

The difference between weak global links and global links is that the object referenced by a weak one can be assembled if necessary (in the absence of memory).

+4
source

If the object has only a weak reference, gc can clear it from memory.

Soft link means a link that does not interfere with gc when it wants to clear an object. But if the object referenced by the soft link, gc will try to keep the object in memory when possible.

-1
source

Source: https://habr.com/ru/post/915198/


All Articles