Menu ▾ ▴

#182 Memory Leak in WrapperManager.listServices

open
nobody
None
5
2012-12-11
2007-08-08
Anonymous
No

Hello,

I found a memory leak in WrapperManager.listServices().

The problem seems to be in the windows native code.

The attached program will demonstrate the leak.
The java heapsize won't grow but the Memory-size in
the taskmanager will grow and grow.

I'm using:
Microsoft WindowsXP
Java Service Wrapper 3.2.3

Maybe it's this: (I'm no expert C-programmer anymore)
In the native code I see on line 823:
services = malloc(size);
This structure is never 'freed'.

Discussion

  • Nobody/Anonymous

     
  • Nobody/Anonymous

    Logged In: NO

    I forgot to mention the file which I think has the memoryleak:

    ./src/c/wrapperjni_win.c

     
  • Nobody/Anonymous

    Logged In: NO

    I can confirm that the line 823 in wrapperjni_win.c is indeed the memoryleak.

    I compiled the library on windows and ran "Test5.java" again (see attached) and
    it showed no memoryleak anymore in the taskmanager.

    The solution was to add the following code just before 'CloseServiceHandle(hSCManager)' :
    if(services != NULL) {
    free(services);
    }

     

Log in to post a comment.