Memory Leak problem

I am having a problem where I am getting a memory leak when trying to use the webMethods Java admin API. I am writing a Java program to pull information out of broker server clients via the API.

Since the broker server may be down when I first attempt to grab that information, my program tests first to see if the server is available. I do this by attempting to instantiate a BrokerServerClient and catch the resulting BrokerCommunicationFailureException if the connection failed. This resulted in many instances of BrokerConnection objects that never get cleaned up by Java garbage collection.

Taking a different approach, I then tried to use BrokerServerClient.getServerProcessRunStatus().

With both approaches, a BrokerConnection object is apparently created and tracked internally, so that if the server remains unreachable it is never garbage collected and results in a memory leak.

Anybody have any suggestions? Thanks in advance.

With your first approach, after getting the BrokerConnection Exception, did you try explicitely setting the BrokerConnection object to null.
This should enable the GC to get rid of it.

Edward,

Thanks for your suggestion. But I don’t have access to the BrokerConnection object, it gets created internally in the WM API when I try to instantiate a new BrokerServerClient. The only reason I even know the BrokerConnection objects exist is because I’m using a memory analysis program (optimizeit).

I guess I can try setting the BrokerServerClient to null, but since it gets instantiated within the “try”, I don’t think its even getting set to anything.

Thanks again for your response