JNA Memory Leak - How to fix?

前端 未结 1 503
死守一世寂寞
死守一世寂寞 2021-01-23 02:11
        public static User32 USER32_INSTANCE = (User32) Native.loadLibrary(\"user32\", User32.class);

        user32 = USER32_INSTANCE;

        user32.EnumWindows((hWn         


        
相关标签:
1条回答
  • 2021-01-23 03:15

    After opening a handle to a process with OpenProcess, you need to close the process handle with CloseHandle. Remember that OpenProcess returns a Handle, not a Pointer.

    Kernel32.INSTANCE.CloseHandle(process);
    

    Note also that JNA provides a pretty in-depth mapping of the Windows API out of the box in the net.java.dev.jna-platform package (I think?)

    0 讨论(0)
提交回复
热议问题