メモリ リークの問題が発生しており、以下のコードが原因であると思われます。シングルトン クラスに静的メソッドがあり、直接参照されている間にメモリ リークが発生しているのではないかと疑っています。
// This class is wired in spring xml and loaded as spring bean
public class SpringSingletonRestClient{
// instance method to make a web-service call
public ServiceResponse getResponseFromARestService(String RequestParam){.....}
// public static helper bean mapping method, that is used outside this class
// for converting the service response object to different object
public static DomainResponse convertServiceResponseToDomainResponse(ServiceResponse serviceResponse){ //conversion logic.... }
}
}
使用法
Class MainClass {
//injected as spring bean
SpringSingletonRestClient client;
public void someMethod(){
ServiceResponse serviceResponse = client.getResponseFromARestService(...);
DomainResponse domainResponse = SpringSingletonRestClient.convertServiceResponseToDomainResponse(serviceResponse);
// use domainResponse object
.......
.......
}
}
疑似を追加したばかりなので、さらに明確にする必要がある場合はお知らせください。メモリ使用量が高くなっており、Spring によって開始されたクラスで宣言されている静的メソッドを使用すると、ガベージ コレクションが正しく行われず、メモリ リークが発生していると思われます。
質問 - 静的メソッドが直接参照によって使用され、そのインスタンス変数によって使用されていない場合でも、Spring によって開始されたシングルトン クラスに静的メソッドがあるのは悪いことですか。