Error : java.lang.OutOfMemoryError: Java heap space

520 views
Skip to first unread message

Abhishek kumar

unread,
Sep 6, 2011, 12:21:48 AM9/6/11
to mongodb-user
In my InteliJ IDEA, I am doing the following,
-------------------------------------------
@Bean
public DB mongoDB(){
DB mDB=null;
try{
Mongo m = new Mongo("localhost",27017);
mDB = m.getDB("test");
boolean auth =
mDB.authenticate("user","password".toCharArray());
------------------------------------------
and it is showing an error

Caused by:
java.lang.OutOfMemoryError: Java heap space
at java.nio.HeapCharBuffer.<init>(HeapCharBuffer.java:39)
at java.nio.CharBuffer.allocate(CharBuffer.java:312)
at com.mongodb.ByteEncoder.<init>(ByteEncoder.java:527)
at com.mongodb.ByteEncoder.<init>(ByteEncoder.java:47)
at com.mongodb.ByteEncoder$1.createNew(ByteEncoder.java:78)
at com.mongodb.ByteEncoder$1.createNew(ByteEncoder.java:75)
at com.mongodb.util.SimplePool._get(SimplePool.java:140)
at com.mongodb.util.SimplePool.get(SimplePool.java:106)
at com.mongodb.util.SimplePool.get(SimplePool.java:95)
at com.mongodb.ByteEncoder.get(ByteEncoder.java:65)
at com.mongodb.DBApiLayer$MyCollection.find(DBApiLayer.java:295)
at com.mongodb.DBCollection.findOne(DBCollection.java:332)
at com.mongodb.DBCollection.findOne(DBCollection.java:321)
at com.mongodb.DB.command(DB.java:115)
at com.mongodb.DB._doauth(DB.java:287)
at com.mongodb.DB.authenticate(DB.java:273)
at com.directi.train.miniTwitter.AppConfig.mongoDB(AppConfig.java:
43)
at com.directi.train.miniTwitter.AppConfig$$EnhancerByCGLIB$
$e8029955.CGLIB$mongoDB$1(<generated>)


in above error, at
com.directi.train.miniTwitter.AppConfig.mongoDB(AppConfig.java:43) :
boolean auth = mDB.authenticate("user","password".toCharArray());

The application is running well when connected to mysql, but when I
just try to connect to mongoDB(just for testing purpose) it is giving
error, I don't find Heap Size is an issue...

Any Help ??

Eliot Horowitz

unread,
Sep 6, 2011, 12:46:23 AM9/6/11
to mongod...@googlegroups.com
What heap size are you running with?
The driver will allocate a medium size buffer, but shouldn't be an issue.

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

Abhishek kumar

unread,
Sep 6, 2011, 2:11:01 AM9/6/11
to mongodb-user
At the bottom right in intelij IDEA its showing 96M of 496M, so I
don't memory is a issue, earlier the application use to run smoothly,
now I just connected to mongodb and used the authenticate function and
its showing the above error.
Please suggest what to do..

Zack Radick

unread,
Sep 6, 2011, 1:07:20 PM9/6/11
to mongod...@googlegroups.com
The 96M out of 496M is your IDE memory usage.  It has nothing to do with programs you launch through the IDE, which run in their own JVMs.  Each run target you configure can be set with specific JVM settings, which you probably need to adjust in this case.
Cheers,
--Zack

Antoine Girbal

unread,
Sep 13, 2011, 5:00:33 PM9/13/11
to mongodb-user
did you find a solution to your issue?
the default JVM heap size should be enough to run basic mongo
programs.
Maybe your IDE starts them with a lower heap setting, you should be
able to tell by looking at the command line that get called from the
IDE (use task manager or "ps").
Reply all
Reply to author
Forward
0 new messages