java.sql.SQLException: out of memory

1,965 views
Skip to first unread message

hgk

unread,
Aug 27, 2010, 4:35:45 PM8/27/10
to Xerial
Hi All,

I am using sqlite-jdbc version 3.6.16 on Windows 7 (dual core, 4GB
RAM, 32bit OS)

When I use multiple threads(upto 10) to access db for read operations
I get Out of memory exceptions.
Each thread has its own connection to the db.

java.sql.SQLException: out of memory
at org.sqlite.DB.throwex(DB.java:380)
at org.sqlite.RS.next(RS.java:137)

My VM settings are

-Xms128m -Xmx768m -XX:MaxPermSize=256m

I checked memory usage using the following API before the exception
happens:

MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
System.out.println("Heap used " +bean.getHeapMemoryUsage().getUsed()/
(1024*1024));
System.out.println("NonHeap used "
+bean.getNonHeapMemoryUsage().getUsed()/(1024*1024) );

Heap used 56 MB
NonHeap used 48 MB

Why does Xerial run out of memory? Is there any memory setting that I
should specify on Xerial?

Thanks,
Bindu

Taro L. Saito

unread,
Aug 28, 2010, 8:50:35 AM8/28/10
to Xerial
Hi,

out of memory error ini SQLite usually means missing database files.
Check your db path specified when creating database connections.

Weihan Wang

unread,
Aug 28, 2010, 1:54:59 PM8/28/10
to xer...@googlegroups.com
Try "-XX:+HeapDumpOnOutOfMemoryError" to generate a core dump on heap
overflow and then use jhat (part of Sun JDK) to analyze the dump file
and find out memory leaks?

Weihan

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

hgk

unread,
Aug 29, 2010, 7:07:45 PM8/29/10
to Xerial
This is definitely out of memory situation because sometimes the
exception occurs when running second or third query. And the javaw.exe
shoots upto 1,117 MB when the exception occurs. I will try to analyze
the dump file. May be there are limitations on how many dbs can be
opened at any given time.

-Bindu
> > For more options, visit this group athttp://groups.google.com/group/xerial?hl=en.- Hide quoted text -
>
> - Show quoted text -
Message has been deleted

Taro L. Saito

unread,
Aug 31, 2010, 7:58:14 PM8/31/10
to Xerial

I guess it is a bug, not the limitation of sqlite or sqlite-jdbc.

I need a test code for reproducing the problem in my environment.
Another person also reported a similar problem when opening/closing
many connections.


On Aug 31, 5:24 am, hgk <hkos...@yahoo.com> wrote:
> Hi Taro,
>
> I am not getting core dump file. Could be because I am getting
> java.sql.SQLException not java.lang.OutOfMemoryError.
>
> My db size is 260MB. I have one large table Tbl1 with 15 columns and
> 1.3 million rows and 20 other small tables.
>
> 10 Threads open the same db and run queries on it. Most of the time I
> get the exception when running the following query.
>
> Select id,name,size from Tbl1 Where ((Extension IN (47))) order by
> size desc limit 500
>
> This does not happen when I use single thread or 2 threads. Does not
> happen with smaller dbs also.
>
> Is this a limitation or a bug? If this is a limitation, is there a
> documentation that talks about the limits.
>
> Thanks,
> Bindu
> > > > For more options, visit this group athttp://groups.google.com/group/xerial?hl=en.-Hidequoted text -
>
> > > - Show quoted text -- Hide quoted text -

hgk

unread,
Sep 1, 2010, 11:02:08 AM9/1/10
to Xerial
Thanks for your reply. I will send a test case to you next week.
> > > > > For more options, visit this group athttp://groups.google.com/group/xerial?hl=en.-Hidequotedtext -

hgk

unread,
Sep 3, 2010, 10:34:01 AM9/3/10
to Xerial
I have submitted the bug http://code.google.com/p/xerial/issues/detail?id=78

We are using PRAGMA page_size=32768

Looks like sqlite is not using virtual memory. As soon as it runs out
of physical memory, I get the exception.

hgk

unread,
Sep 3, 2010, 3:08:44 PM9/3/10
to Xerial
To workaround this, we set the following in our application
PRAGMA cache_size =100


On Sep 3, 10:34 am, hgk <hkos...@yahoo.com> wrote:
> I have submitted the bughttp://code.google.com/p/xerial/issues/detail?id=78

Pradev Movva

unread,
Sep 17, 2010, 9:19:54 AM9/17/10
to xer...@googlegroups.com
Bindu -

I had the similar situation in the past. Is the SQLite datbase flat
file is located on a remote machine than from your JSP page from where
you are trying to connect to? If your poblem hasn't solved I would try
moving the file to the same server/machine and then give it a try.

Connection con = null;
con = DriverManger.getConnection("jdbc:sqlite//ipaddress/DirA/DirB/Sqlite.db");
where ipaddress is the address of a remote machine and THIS WON'T WORK
and gives you 'out of memory' exception

instead try
con = DriverManger.getConnection("jdbc:sqlite:C:/<DirName>/Sqlite.db");
THIS WORKS.

SQLite is not a stand alone database so it never worked for me when
try to connect to it when it was on a remote machine.

Hope this helps.

Dev

Reply all
Reply to author
Forward
0 new messages