简体   繁体   中英

Is memory used by a JNI DLL returned when the Java process exits?

I have inherited the maintenance of a small Java project, with a DLL dependency (JNI). The java program is called with a set of parameters, which are sent forward to the DLL (and further on to a third party API). In- and output are simple strings.

The memory used by the DLL, is that allocated from the java process' heap? And does that, as a consequence, mean that all memory in this process (incl. that used by the DLL) is returned to the system when the java program exits?

(We're talking Windows Server 2008 and Java 1.6, if details like that matter.)

The Operating System is responsible for cleaning up all memory allocated by a process when the process terminates.

DLLs are loaded "into" the process.

Thus, when the JVM [process] terminates all the memory -- including the memory allocated by the DLLs -- will be reclaimed by the OS.

Note that this excludes external resources, such as those from other [sub-]processes which were launched but not terminated or shared resources that still have open handles elsewhere, or resources otherwise outside the OS control (eg a distributed cache).

Happy coding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM