My system suffer from memory leak, i try to optimize it by releasing memory as soon as possible.
- Is this a good use of the finalize method?
Where to i catch the "Throwable" object?
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 ... // .....
}