Menu ▾ ▴

#159 Memory Leak in listServices

v3.2.3
open-fixed
JNI (8)
7
2007-03-15
2007-02-22
Anonymous
No

We have several java services running using JSW. An additional service monitors them and sends information about their states. We detected that after several hours the server started to swap. Using the SysInternals ProcessExplorer we detected the monitor service to hog memory.

The problem is reproducable using the following code-snipplet and the processexplorer (TaskManager should do the job, too)

------------->

package com.smsdemag.de.ve.lib.win32service;

import org.tanukisoftware.wrapper.WrapperManager;
import org.tanukisoftware.wrapper.WrapperWin32Service;

public class Test
{
public static void main(String[] args)
{
while(true)
{
for(final WrapperWin32Service service : WrapperManager.listServices())
{
// We monitor the services here...
}
try
{
Thread.sleep(1000);
}
catch(InterruptedException e)
{}
}
}
}

<------------------------------------

When executing the code, you see memory consumption of the JVM increasing about 100 kb every few seconds.

I don't know the C-side implementation, but it would be nice to offer a public dispose()-method, which frees the resources. Additionally the finalize() method should call dispose().

Regards,
Sebastian Kopsan

Discussion

  • Leif Mortenson

    Leif Mortenson - 2007-03-15
    • milestone: --> v3.2.3
    • priority: 5 --> 7
    • assigned_to: nobody --> mortenson
    • status: open --> open-accepted
     
  • Leif Mortenson

    Leif Mortenson - 2007-03-15

    Logged In: YES
    user_id=228081
    Originator: NO

    Sebastian,
    Thanks for pointing this out. I have confirmed the problem and will look into it.

    Cheers,
    Leif

     
  • Leif Mortenson

    Leif Mortenson - 2007-03-15
    • status: open-accepted --> open-fixed
     
  • Leif Mortenson

    Leif Mortenson - 2007-03-15

    Logged In: YES
    user_id=228081
    Originator: NO

    Sebastian,
    Ok. This has been fixed. I was forgetting to free up a malloced array. Surprised I missed it, the leak was fairly significant.

    The API remains unchanged. The list you receive from the WrapperManager.listServices call will get GCed like any other Java array.

    This fix will be in the upcoming 3.2.4 release.

    Cheers,
    Leif

     
  • Nobody/Anonymous

    Logged In: NO

    Thank you for fixing it...and for the JSW project itself :)

    Thank you very much.

    Regards,
    Sebastian Kopsan

     

Log in to post a comment.