私のシステムはメモリ リークに悩まされています。できるだけ早くメモリを解放して最適化しようとしています。
- これはファイナライズメソッドの良い使い方ですか?
「Throwable」オブジェクトはどこでキャッチできますか?
public class OrderSendBulkHandler extends PandaSoapHandler { // <login,Data> private HashMap<String,OrderSendBulkData> followersData = new HashMap<String,OrderSendBulkData>(); // <login,error_code> private HashMap<String,BulkDataResponse> positionResponses = new HashMap<String,BulkDataResponse>(); private Position position; private Float guruBalance; private float partialRatio = -1; private boolean ignorePosition = false; @Override protected void finalize() throws Throwable { try { followersData.clear(); followersData = null; positionResponses.clear(); positionResponses = null; position = null; guruBalance = null; } catch (Exception e) { e.printStackTrace(); } super.finalize();
}
// more code of the class here ... // .....
}