Hey Everyone,
I just upgraded to Beta-Prod 3 and still having Out of memory exceptions on
the server side. To test to see if I didn't have memory leaks in my own
beans, I completely scraped those and created a dummy Entity Bean - attached
below - Using BMP but just ignoring the ejbSaves / ejbCreate and not
persisting anything. If I create upwards of 150,000 objects from clients
and I get OOM on the server i.e.:
[TestingHome] --Create--167657
[TestingHome] TRANSACTION ROLLBACK EXCEPTION:null; nested exception is:
java.lang.OutOfMemoryError
[TestingHome] java.lang.OutOfMemoryError
[TestingHome] <<no stack trace available>>
My bean has a sample main client build in so you can see what I am doing...
Is there a setting somewhere on the max number of cached objects???
public class TestingBean implements EntityBean {
public int cnt = 0;
/**
* Retrieve id
*/
public int getCount() throws RemoteException {
return (int)id;
}
/**
* Get string test
*
* @parm s - string to retrieve
*/
public String getStr() throws RemoteException {
return id+"";
}
long id = 0;
static long _cnt = 1000;
public String ejbCreate() throws RemoteException {
id = _cnt++;
System.out.println("--Create--" + id);
return id+"";
}
public void ejbPostCreate() throws RemoteException {
System.out.println("--PostCreate--" + id);
}
public void ejbActivate() throws RemoteException {
System.out.println("--Activate--" + id);
}
public void ejbPassivate() throws RemoteException {
System.out.println("--Passivate--" + id);
}
public void ejbRemove() throws RemoteException {
System.out.println("--Remove--" + id);
}
public void ejbLoad() throws RemoteException {
String pk = (String) ((EntityContext)context).getPrimaryKey();
System.out.println("--Load--" + pk);
id = (new Long(pk)).longValue();
}
public void ejbStore() throws RemoteException {
String pk = (String) ((EntityContext)context).getPrimaryKey();
System.out.println("--Store--" + pk);
id = (new Long(pk)).longValue();
}
transient private EntityContext context;
public void setEntityContext(EntityContext ctx) throws RemoteException {
context = ctx;
}
public EntityContext getEntityContext() throws RemoteException {
return context;
}
public void unsetEntityContext() {
context = null;
}
public String ejbFindByPrimaryKey(String key) throws
ObjectNotFoundException, FinderException {
return key;
}
public Enumeration ejbFindAllObjects() throws ObjectNotFoundException,
FinderException {
return (new Vector()).elements();
}
public Enumeration ejbFindByQuery(String q) throws
ObjectNotFoundException, FinderException {
return (new Vector()).elements();
}
public static Properties getBeanProps() {
Properties props = new Properties();
try {
InputStream fin;
fin = new BufferedInputStream(
ClassLoader.getSystemClassLoader().getSystemResourceAsStream("BeanConfig.pro
ps"));
props.load( fin );
fin.close();
} catch (Exception e) {
System.out.println(e);
}
return props;
}
public static void main(String args[]){
try {
Hashtable env = new Hashtable();
Properties p = getBeanProps();
env.put("java.naming.provider.url","localhost:1099");
env.put("java.naming.factory.initial",
p.getProperty("java.naming.factory.initial",""));
env.put("java.naming.factory.url.pkgs",
p.getProperty("java.naming.factory.url.pkgs","") );
Context initialContext = new InitialContext(env);
TestingHome server = (TestingHome)
initialContext.lookup("TestingHome");
int max = 5000;
try {
max = (new Integer( args[0] )).intValue();
} catch (Exception e) {}
Vector v = new Vector();
System.out.println("Creating " + max + " Test beans.");
for(int i=0;i<max;i++) {
v.add( server.create().getPrimaryKey() );
}
System.out.println("Finding " + max + " Test beans.");
for(int i=0;i<max;i++) {
server.findByPrimaryKey( (String) v.elementAt(i) );
}
System.out.println("Executing method " + max + " Test beans.");
for(int i=0;i<max;i++) {
server.findByPrimaryKey( (String) v.elementAt(i) ).getCount();
}
System.out.println("Removing " + max + " Test beans.");
for(int i=0;i<max;i++) {
server.findByPrimaryKey( (String) v.elementAt(i) ).remove();
}
} catch (Exception e2) {
System.out.println(e2);
}
}
}
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]