niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Berkeley DB
Many calls to DbEnv.open cause out of memory errors
Post new topic   Reply to topic Page 1 of 1 [7 Posts] View previous topic :: View next topic
Author Message
melvin12harmon@yahoo.com
*nix forums beginner


Joined: 25 Feb 2005
Posts: 9

PostPosted: Fri Mar 11, 2005 12:01 am    Post subject: Re: Many calls to DbEnv.open cause out of memory errors Reply with quote

Sigh. I was really running out of memory.

Each single test was opening an env in a new temp dir.
When the test was done I was just deleting the temp dir.
This worked fine when until I started running 40+ tests in one JVM.
Just closing the env before deleting the temp dir fixed everything.

I'm still not sure exactly what kind of memory I was running out of...

Thanks for asking the right questions,
-m
Back to top
Michael Cahill
*nix forums Guru Wannabe


Joined: 26 May 2005
Posts: 219

PostPosted: Thu Mar 10, 2005 10:03 pm    Post subject: Re: Many calls to DbEnv.open cause out of memory errors Reply with quote

Is it possible that you are really running out of memory? How many
environment handles are open concurrently? Are they all handles on the
same environment directory, or is each one a separate environment? Is
there any other error message generated on the Berkeley DB error
stream?

Can you post the code that you use to configure the environment handles
(cache size, number of locks, and so on)?

Regards,
Michael.
Back to top
melvin12harmon@yahoo.com
*nix forums beginner


Joined: 25 Feb 2005
Posts: 9

PostPosted: Thu Mar 10, 2005 6:15 pm    Post subject: Re: Many calls to DbEnv.open cause out of memory errors Reply with quote

I applied the patch but I still get the same error.
I added some debug code to verify that I am using the patch.

Is there any other info I can provide
that might help diagnose my problem?

thanks,
-m
Back to top
bostic@sleepycat.com
*nix forums beginner


Joined: 21 Jun 2005
Posts: 49

PostPosted: Fri Mar 04, 2005 12:37 am    Post subject: Re: Many calls to DbEnv.open cause out of memory errors Reply with quote

Quote:
I get 'malformed patch' errors due to the line wrapping.
Is this file available for download?

This is an official bug fix for the Berkeley DB 4.2.52 release,
posted to the Sleepycat Software web site, at:

http://www.sleepycat.com/update/4.2.52/patch.4.2.52.html

Quote:
Also, is there a list of know 4.2.52 bugs?

No. There is a list of changes made between the Berkeley DB
4.2.52 and 4.3.27 releases:

http://www.sleepycat.com/update/4.3.27/if.4.3.27.html

Regards,
--keith

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Keith Bostic bostic@sleepycat.com
Sleepycat Software Inc. keithbosticim (Yahoo)
118 Tower Rd. +1-781-259-3139
Lincoln, MA 01773 http://www.sleepycat.com
Back to top
melvin12harmon@yahoo.com
*nix forums beginner


Joined: 25 Feb 2005
Posts: 9

PostPosted: Wed Mar 02, 2005 7:13 pm    Post subject: Re: Many calls to DbEnv.open cause out of memory errors Reply with quote

Hi,

I get 'malformed patch' errors due to the line wrapping.
Is this file available for download?

Also, is there a list of know 4.2.52 bugs?

thanks
-m
Back to top
Ron
*nix forums Guru Wannabe


Joined: 01 Apr 2005
Posts: 157

PostPosted: Tue Mar 01, 2005 2:43 pm    Post subject: Re: Many calls to DbEnv.open cause out of memory errors Reply with quote

melvin12harmon@yahoo.com wrote:
Quote:
I am using the java API to db-4.2.52.

My application tests often open hundreds of DbEnv's in a single JVM.
After a while I get the following error:

[junit] PANIC: Cannot allocate memory
[junit] com.sleepycat.db.DbRunRecoveryException: DB_RUNRECOVERY:
Fatal error, run database recovery: DB_RUNRECOVERY: Fatal error, run
database recovery
[junit] at com.sleepycat.db.db_javaJNI.DbEnv_open0(Native
Method)
[junit] at com.sleepycat.db.DbEnv.open0(DbEnv.java:1574)
[junit] at com.sleepycat.db.DbEnv.open(DbEnv.java:702)


What memory setting do I need to change to fix this error?

thanks,
-m

There is a known bug in this area in DB 4.2.52 that is fixed in DB 4.3.
I've
attached the patch for this problem. Please apply the patch from the
root directory of the 4.2.52 source tree and let me know if this works
for you.

Ron


--- java/src/com/sleepycat/db/DbEnv.java 2003-12-03 16:26:27.000000000
-0500
+++ java/src/com/sleepycat/db/DbEnv.java 2004-03-18 15:15:42.000000000
-0500
@@ -61,7 +61,7 @@
// Internally, the JNI layer creates a global reference to each
DbEnv,
// which can potentially be different to this. We keep a copy
here so
// we can clean up after destructors.
- private Object dbenv_ref;
+ private long dbenv_ref;
private DbAppDispatch app_dispatch_handler;
private DbEnvFeedbackHandler env_feedback_handler;
private DbErrorHandler error_handler;
@@ -94,7 +94,7 @@
void cleanup() {
swigCPtr = 0;
db_java.deleteRef0(dbenv_ref);
- dbenv_ref = null;
+ dbenv_ref = 0L;
}


--- java/src/com/sleepycat/db/Db.java 2003-12-03 16:26:25.000000000
-0500
+++ java/src/com/sleepycat/db/Db.java 2004-03-18 15:15:55.000000000
-0500
@@ -57,7 +57,7 @@
// Internally, the JNI layer creates a global reference to each
Db,
// which can potentially be different to this. We keep a copy
here so
// we can clean up after destructors.
- private Object db_ref;
+ private long db_ref;
private DbEnv dbenv;
private boolean private_dbenv;
private DbAppendRecno append_recno_handler;
@@ -84,7 +84,7 @@
private void cleanup() {
swigCPtr = 0;
db_java.deleteRef0(db_ref);
- db_ref = null;
+ db_ref = 0L;
if (private_dbenv) {
dbenv.cleanup();
}
--- java/src/com/sleepycat/db/db_java.java 2003-12-03
16:10:54.000000000 -0500
+++ java/src/com/sleepycat/db/db_java.java 2004-03-18
15:17:24.000000000 -0500
@@ -14,15 +14,15 @@
db_javaJNI.DbEnv_lock_vec(DbEnv.getCPtr(dbenv), locker, flags,
list, offset, nlist);
}

- static Object initDbEnvRef0(DbEnv self, Object handle) {
+ static long initDbEnvRef0(DbEnv self, Object handle) {
return db_javaJNI.initDbEnvRef0(DbEnv.getCPtr(self), handle);
}

- static Object initDbRef0(Db self, Object handle) {
+ static long initDbRef0(Db self, Object handle) {
return db_javaJNI.initDbRef0(Db.getCPtr(self), handle);
}

- static void deleteRef0(Object ref) {
+ static void deleteRef0(long ref) {
db_javaJNI.deleteRef0(ref);
}

--- java/src/com/sleepycat/db/db_javaJNI.java 2003-12-03
16:10:55.000000000 -0500
+++ java/src/com/sleepycat/db/db_javaJNI.java 2004-03-18
15:16:18.000000000 -0500
@@ -45,9 +45,9 @@
static native final void initialize();

public final static native void DbEnv_lock_vec(long jarg1, int
jarg2, int jarg3, DbLockRequest[] jarg4, int jarg5, int jarg6) throws
DbException;
- final static native Object initDbEnvRef0(long jarg1, Object jarg2);
- final static native Object initDbRef0(long jarg1, Object jarg2);
- final static native void deleteRef0(Object jarg1);
+ final static native long initDbEnvRef0(long jarg1, Object jarg2);
+ final static native long initDbRef0(long jarg1, Object jarg2);
+ final static native void deleteRef0(long jarg1);
final static native long getDbEnv0(long jarg1);
public final static native long new_Db(long jarg1, int jarg2) throws
DbException;
public final static native void Db_associate(long jarg1, long jarg2,
long jarg3, DbSecondaryKeyCreate jarg4, int jarg5) throws DbException;
--- libdb_java/db_java.i 2003-11-17 15:00:52.000000000 -0500
+++ libdb_java/db_java.i 2004-03-18 09:21:14.000000000 -0500
@@ -53,7 +53,7 @@
// Internally, the JNI layer creates a global reference to each
DbEnv,
// which can potentially be different to this. We keep a copy here
so
// we can clean up after destructors.
- private Object dbenv_ref;
+ private long dbenv_ref;
private DbAppDispatch app_dispatch_handler;
private DbEnvFeedbackHandler env_feedback_handler;
private DbErrorHandler error_handler;
@@ -76,7 +76,7 @@
void cleanup() {
swigCPtr = 0;
db_java.deleteRef0(dbenv_ref);
- dbenv_ref = null;
+ dbenv_ref = 0L;
}

public synchronized void close(int flags) throws DbException {
@@ -220,7 +220,7 @@
// Internally, the JNI layer creates a global reference to each Db,
// which can potentially be different to this. We keep a copy here
so
// we can clean up after destructors.
- private Object db_ref;
+ private long db_ref;
private DbEnv dbenv;
private boolean private_dbenv;
private DbAppendRecno append_recno_handler;
@@ -245,7 +245,7 @@
private void cleanup() {
swigCPtr = 0;
db_java.deleteRef0(db_ref);
- db_ref = null;
+ db_ref = 0L;
if (private_dbenv)
dbenv.cleanup();
dbenv = null;
@@ -503,46 +503,42 @@
}
%}

-%native(initDbEnvRef0) jobject initDbEnvRef0(DB_ENV *self, void
*handle);
-%native(initDbRef0) jobject initDbRef0(DB *self, void *handle);
-%native(deleteRef0) void deleteRef0(jobject ref);
+%native(initDbEnvRef0) jlong initDbEnvRef0(DB_ENV *self, void
*handle);
+%native(initDbRef0) jlong initDbRef0(DB *self, void *handle);
+%native(deleteRef0) void deleteRef0(jlong ref);
%native(getDbEnv0) DB_ENV *getDbEnv0(DB *self);

%{
-JNIEXPORT jobject JNICALL
Java_com_sleepycat_db_db_1javaJNI_initDbEnvRef0(
+JNIEXPORT jlong JNICALL
Java_com_sleepycat_db_db_1javaJNI_initDbEnvRef0(
JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg2) {
DB_ENV *self = *(DB_ENV **)&jarg1;
+ jlong ret;
COMPQUIET(jcls, NULL);

DB_ENV_INTERNAL(self) = (void *)(*jenv)->NewGlobalRef(jenv, jarg2);
self->set_errpfx(self, (const char*)self);
- return (jobject)DB_ENV_INTERNAL(self);
+ *(jobject *)&ret = (jobject)DB_ENV_INTERNAL(self);
+ return (ret);
}

-JNIEXPORT jobject JNICALL
Java_com_sleepycat_db_db_1javaJNI_initDbRef0(
+JNIEXPORT jlong JNICALL Java_com_sleepycat_db_db_1javaJNI_initDbRef0(
JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg2) {
DB *self = *(DB **)&jarg1;
+ jlong ret;
COMPQUIET(jcls, NULL);

DB_INTERNAL(self) = (void *)(*jenv)->NewGlobalRef(jenv, jarg2);
- return (jobject)DB_INTERNAL(self);
+ *(jobject *)&ret = (jobject)DB_INTERNAL(self);
+ return (ret);
}

JNIEXPORT void JNICALL Java_com_sleepycat_db_db_1javaJNI_deleteRef0(
- JNIEnv *jenv, jclass jcls, jobject jref) {
- COMPQUIET(jcls, NULL);
-
- if (jref != NULL)
- (*jenv)->DeleteGlobalRef(jenv, jref);
-}
-
-JNIEXPORT jobject JNICALL Java_com_sleepycat_db_db_1javaJNI_getDbRef0(
JNIEnv *jenv, jclass jcls, jlong jarg1) {
- DB *self = *(DB **)&jarg1;
+ jobject jref = *(jobject *)&jarg1;
COMPQUIET(jcls, NULL);
- COMPQUIET(jenv, NULL);

- return (jobject)DB_INTERNAL(self);
+ if (jref != 0L)
+ (*jenv)->DeleteGlobalRef(jenv, jref);
}

JNIEXPORT jlong JNICALL Java_com_sleepycat_db_db_1javaJNI_getDbEnv0(
@@ -554,7 +550,7 @@
COMPQUIET(jcls, NULL);

*(DB_ENV **)&env_cptr = self->dbenv;
- return env_cptr;
+ return (env_cptr);
}

JNIEXPORT jboolean JNICALL
--- libdb_java/db_java_wrap.c 2003-12-03 16:10:36.000000000 -0500
+++ libdb_java/db_java_wrap.c 2004-03-18 12:18:58.000000000 -0500
@@ -1192,40 +1192,36 @@
}


-JNIEXPORT jobject JNICALL
Java_com_sleepycat_db_db_1javaJNI_initDbEnvRef0(
+JNIEXPORT jlong JNICALL
Java_com_sleepycat_db_db_1javaJNI_initDbEnvRef0(
JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg2) {
DB_ENV *self = *(DB_ENV **)&jarg1;
+ jlong ret;
COMPQUIET(jcls, NULL);

DB_ENV_INTERNAL(self) = (void *)(*jenv)->NewGlobalRef(jenv, jarg2);
self->set_errpfx(self, (const char*)self);
- return (jobject)DB_ENV_INTERNAL(self);
+ *(jobject *)&ret = (jobject)DB_ENV_INTERNAL(self);
+ return (ret);
}

-JNIEXPORT jobject JNICALL
Java_com_sleepycat_db_db_1javaJNI_initDbRef0(
+JNIEXPORT jlong JNICALL Java_com_sleepycat_db_db_1javaJNI_initDbRef0(
JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg2) {
DB *self = *(DB **)&jarg1;
+ jlong ret;
COMPQUIET(jcls, NULL);

DB_INTERNAL(self) = (void *)(*jenv)->NewGlobalRef(jenv, jarg2);
- return (jobject)DB_INTERNAL(self);
+ *(jobject *)&ret = (jobject)DB_INTERNAL(self);
+ return (ret);
}

JNIEXPORT void JNICALL Java_com_sleepycat_db_db_1javaJNI_deleteRef0(
- JNIEnv *jenv, jclass jcls, jobject jref) {
- COMPQUIET(jcls, NULL);
-
- if (jref != NULL)
- (*jenv)->DeleteGlobalRef(jenv, jref);
-}
-
-JNIEXPORT jobject JNICALL Java_com_sleepycat_db_db_1javaJNI_getDbRef0(
JNIEnv *jenv, jclass jcls, jlong jarg1) {
- DB *self = *(DB **)&jarg1;
+ jobject jref = *(jobject *)&jarg1;
COMPQUIET(jcls, NULL);
- COMPQUIET(jenv, NULL);

- return (jobject)DB_INTERNAL(self);
+ if (jref != 0L)
+ (*jenv)->DeleteGlobalRef(jenv, jref);
}

JNIEXPORT jlong JNICALL Java_com_sleepycat_db_db_1javaJNI_getDbEnv0(
@@ -1237,7 +1233,7 @@
COMPQUIET(jcls, NULL);

*(DB_ENV **)&env_cptr = self->dbenv;
- return env_cptr;
+ return (env_cptr);
}

JNIEXPORT jboolean JNICALL
Back to top
melvin12harmon@yahoo.com
*nix forums beginner


Joined: 25 Feb 2005
Posts: 9

PostPosted: Mon Feb 28, 2005 5:56 pm    Post subject: Many calls to DbEnv.open cause out of memory errors Reply with quote

I am using the java API to db-4.2.52.

My application tests often open hundreds of DbEnv's in a single JVM.
After a while I get the following error:

[junit] PANIC: Cannot allocate memory
[junit] com.sleepycat.db.DbRunRecoveryException: DB_RUNRECOVERY:
Fatal error, run database recovery: DB_RUNRECOVERY: Fatal error, run
database recovery
[junit] at com.sleepycat.db.db_javaJNI.DbEnv_open0(Native Method)
[junit] at com.sleepycat.db.DbEnv.open0(DbEnv.java:1574)
[junit] at com.sleepycat.db.DbEnv.open(DbEnv.java:702)


What memory setting do I need to change to fix this error?

thanks,
-m
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [7 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 4:51 am | All times are GMT
navigation Forum index » Databases » Berkeley DB
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Postfix fatal authentication errors! JamesMaxwell Postfix 0 Tue Oct 28, 2008 3:37 pm
No new posts Artica-postfix a full Open Source postfix management console dtouzeau Postfix 0 Mon Jun 16, 2008 9:46 pm
No new posts postfix out of memory error - please help metind Postfix 0 Mon Sep 11, 2006 1:54 am
No new posts Non IBM memory in p630 Ron AIX 0 Fri Jul 21, 2006 2:05 pm
No new posts database Share Memory Limit (2 GB ) in a Instance is tota... sadanjan@gmail.com IBM DB2 0 Fri Jul 21, 2006 12:57 pm

Web Advertising | Internet Advertising | Record Internet Radio with Tags | Credit Cards | Discount TVs
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.3115s ][ Queries: 20 (0.2079s) ][ GZIP on - Debug on ]