Java:当DLL由ClassLoader加载时,它们在哪里存储在内存中? [英] Java: When DLLs are loaded by a ClassLoader where are they stored in memory?
问题描述
我的理解是 java.library.path
中c> ClassLoader ,但是它们在 System.loadLibrary()
和 System.load()之后存储在内存中的位置。是通过非静态过程调用code>吗?
My understanding is that the .dlls
are loaded into java.library.path
by a ClassLoader
but where are they stored in memory after System.loadLibrary()
and System.load()
is called from a non-static procedure?
推荐答案
当 System.loadLibrary()
或 System.load()
函数被调用,当前Java类的 ClassLoader
的任务是查找请求的DLL(及其依赖项),并通知操作系统有关库位置的信息。 ClassLoader
本身不执行任何加载:此操作使用Java本机接口(JNI)库与操作系统进行通信,并告诉它在哪里查找所请求的库。
When the System.loadLibrary()
or System.load()
functions are called, the ClassLoader
for the current Java class is tasked with finding the requested DLL (and its dependencies) and informing the operating system about the libraries' locations. The ClassLoader
itself does not perform any loading: this operation uses the Java Native Interface (JNI) libraries to communicate with the operating system and tells it where to look for the requested libraries.
调用DLL函数时,该函数将被加载到Java VM进程的地址空间中并在其中执行。该地址空间是操作系统分配给进程的内存块,与Java VM完全分开。因此,您问题的答案是Java VM仅使用其给定的地址空间按需加载DLL函数并通过Java本机接口执行它们。
When a DLL function is called, the function is loaded into the address space of the Java VM process and is executed there. This address space is a memory block given to a process by the operating system and is separate from the Java VM altogether. So, the answer to your question is that the Java VM simply uses its given address space to load DLL functions on-demand and executes them through the Java Native Interface.
源: http://www.webbasedprogramming.com/Tricks- Java编程大师/ch30.htm
这篇关于Java:当DLL由ClassLoader加载时,它们在哪里存储在内存中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!