Reputation: 284
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.)
Upvotes: 2
Views: 366
Reputation:
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 (e.g. a distributed cache).
Happy coding.
Upvotes: 5