IDEMPIERE-3653 1007767 Possible memory leak. Fixed memory leak and reduce memory usage. / integrate partial patch from hengsin
This commit is contained in:
parent
8414f71756
commit
2d01ed4995
|
@ -31,6 +31,7 @@ import org.compiere.util.DB;
|
|||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.NamePair;
|
||||
import org.compiere.util.Util;
|
||||
|
||||
/**
|
||||
* Warehouse Locator Lookup Model.
|
||||
|
@ -255,7 +256,7 @@ public final class MLocatorLookup extends Lookup implements Serializable
|
|||
return null;
|
||||
}
|
||||
//
|
||||
return new MLocator (m_ctx, M_Locator_ID, trxName);
|
||||
return Util.isEmpty(trxName) ? MLocator.get(m_ctx, M_Locator_ID) : new MLocator (m_ctx, M_Locator_ID, trxName);
|
||||
} // getMLocator
|
||||
|
||||
/**
|
||||
|
@ -328,7 +329,7 @@ public final class MLocatorLookup extends Lookup implements Serializable
|
|||
int local_only_warehouse_id = getOnly_Warehouse_ID(); // [ 1674891 ] MLocatorLookup - weird error
|
||||
int local_only_product_id = getOnly_Product_ID();
|
||||
|
||||
StringBuilder sql = new StringBuilder("SELECT M_Locator.* FROM M_Locator ")
|
||||
StringBuilder sql = new StringBuilder("SELECT M_Locator.M_Locator_ID FROM M_Locator ")
|
||||
.append(" INNER JOIN M_Warehouse wh ON (wh.M_Warehouse_ID=M_Locator.M_Warehouse_ID) ")
|
||||
.append(" WHERE M_Locator.IsActive='Y' ")
|
||||
.append(" AND wh.IsActive='Y'");
|
||||
|
@ -372,8 +373,8 @@ public final class MLocatorLookup extends Lookup implements Serializable
|
|||
//
|
||||
while (rs.next())
|
||||
{
|
||||
MLocator loc = new MLocator(m_ctx, rs, null);
|
||||
int M_Locator_ID = loc.getM_Locator_ID();
|
||||
int M_Locator_ID = rs.getInt(1);
|
||||
MLocator loc = MLocator.get(m_ctx, M_Locator_ID);
|
||||
m_lookup.put(new Integer(M_Locator_ID), loc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,10 @@ package org.compiere.util;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
|
@ -66,6 +68,7 @@ public class CacheMgt
|
|||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(CacheMgt.class);
|
||||
|
||||
private final static int MAX_SIZE = 2000;
|
||||
|
||||
/**************************************************************************
|
||||
* Create Cache Instance
|
||||
|
@ -94,7 +97,18 @@ public class CacheMgt
|
|||
|
||||
if (map == null)
|
||||
{
|
||||
map = new ConcurrentHashMap<K, V>();
|
||||
map = Collections.synchronizedMap(new LinkedHashMap<K, V>() {
|
||||
/**
|
||||
* generated serial id
|
||||
*/
|
||||
private static final long serialVersionUID = -9111152673370957054L;
|
||||
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Entry<K, V> eldest) {
|
||||
return size() > MAX_SIZE;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
return map;
|
||||
} // register
|
||||
|
|
Loading…
Reference in New Issue