You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Amit Modi <am...@persistent.co.in> on 2005/08/17 12:23:20 UTC

Memory allocation problem

Hello,
  I am using derby for my desktop application. We have our complete 
application in java and
one problem which we are facing is, after doing login and logout 
operation for five to six time
it shows out of memory exception. When I used some profiler, I found out 
that the maximum memory is getting
used in execute() method of derby. Though after each logout I close the 
database and before closing it I close all the statements and
PreparedStatements create during the login.
I think there are live pointer remaining after the database get closed 
pointing to some raw data and result sets.
Can anyone please let me know whatz the best practice to make all the 
pointer point to null, created internally to database.

Thanks in Advance.

Regards:
Amit Modi


Re: Memory allocation problem

Posted by Suresh Thalamati <su...@gmail.com>.
Amit Modi wrote:
> Thanks Suresh for reply,
>    Actually I have different Database for each user and if the user do 
> continuous "change user login" operation though its
> not very usual case in real life but for testing purpose, then its 
> necessary to close the database of  previous user and  open the database
> of new user.
>  One problem which I am facing is, after I shutdown the previous user's 
> database, its not releasing the  complete memory.

To my knowledge after databases are shutdown, I think only memory 
usage related to derby is classes and an AntiGC thread  to avoid 
reloading of the drivers. This should be small.  You can completely 
shutdown the derby system using the URL 'jdbc:derby:shutdown=true' , 
as you are using booting multiple database you may not want to do that.

By the way , How much memory derby is using  after it is shutdown ?


> I will just give you brief description of the steps I am following to 
> close the database,
> 1> Close all the statements and prepared statements.
> 2> Shutdown the database
> 

are u closing the result sets ?



> Can you please let me know, whether there should be something more that 
> I should do?
> 
> Regards:
> Amit Modi
> 
> 
> Suresh Thalamati wrote:
> 
>> Hi Amit,
>>
>> If you are just closing the connections, some of the memory used by
>> the database internal structures will not be released,for example 
>> memory used by the page cache will not be released; default size of 
>> cache is 1000 pages, if cache is full, it can take up 32MB if all 
>> pages are 32K or  4MB if page size is 4K.
>>
>> If you really want to release all the memory used by a derby database 
>> then you need to shutdown the database. If you are frequently 
>> connecting back to the database,  shutting down the database is not a
>> good idea. It will impact the performance of u'r application .
>> First Connection that comes after the shutdown will
>> need to boot the database and also , it will need to reread the
>> data from the disk into the cache if your application is reading the 
>> same data that was in the cache before the shutdown.
>>
>>
>> Thanks
>> -suresht
>>
>>
>> Amit Modi wrote:
>>
>>> Hello,
>>>  I am using derby for my desktop application. We have our complete 
>>> application in java and
>>> one problem which we are facing is, after doing login and logout 
>>> operation for five to six time
>>> it shows out of memory exception. When I used some profiler, I found 
>>> out that the maximum memory is getting
>>> used in execute() method of derby. Though after each logout I close 
>>> the database and before closing it I close all the statements and
>>> PreparedStatements create during the login.
>>> I think there are live pointer remaining after the database get 
>>> closed pointing to some raw data and result sets.
>>> Can anyone please let me know whatz the best practice to make all the 
>>> pointer point to null, created internally to database.
>>>
>>> Thanks in Advance.
>>>
>>> Regards:
>>> Amit Modi
>>>
>>
>>
> 



Re: Memory allocation problem

Posted by Amit Modi <am...@persistent.co.in>.
Thanks Suresh for reply,
    Actually I have different Database for each user and if the user do 
continuous "change user login" operation though its
not very usual case in real life but for testing purpose, then its 
necessary to close the database of  previous user and  open the database
of new user.
  One problem which I am facing is, after I shutdown the previous user's 
database, its not releasing the  complete memory.
 I will just give you brief description of the steps I am following to 
close the database,
1> Close all the statements and prepared statements.
2> Shutdown the database

Can you please let me know, whether there should be something more that 
I should do?

Regards:
Amit Modi


Suresh Thalamati wrote:

> Hi Amit,
>
> If you are just closing the connections, some of the memory used by
> the database internal structures will not be released,for example 
> memory used by the page cache will not be released; default size of 
> cache is 1000 pages, if cache is full, it can take up 32MB if all 
> pages are 32K or  4MB if page size is 4K.
>
> If you really want to release all the memory used by a derby database 
> then you need to shutdown the database. If you are frequently 
> connecting back to the database,  shutting down the database is not a
> good idea. It will impact the performance of u'r application .
> First Connection that comes after the shutdown will
> need to boot the database and also , it will need to reread the
> data from the disk into the cache if your application is reading the 
> same data that was in the cache before the shutdown.
>
>
> Thanks
> -suresht
>
>
> Amit Modi wrote:
>
>> Hello,
>>  I am using derby for my desktop application. We have our complete 
>> application in java and
>> one problem which we are facing is, after doing login and logout 
>> operation for five to six time
>> it shows out of memory exception. When I used some profiler, I found 
>> out that the maximum memory is getting
>> used in execute() method of derby. Though after each logout I close 
>> the database and before closing it I close all the statements and
>> PreparedStatements create during the login.
>> I think there are live pointer remaining after the database get 
>> closed pointing to some raw data and result sets.
>> Can anyone please let me know whatz the best practice to make all the 
>> pointer point to null, created internally to database.
>>
>> Thanks in Advance.
>>
>> Regards:
>> Amit Modi
>>
>
>


Re: Memory allocation problem

Posted by Suresh Thalamati <su...@gmail.com>.
Hi Amit,

If you are just closing the connections, some of the memory used by
the database internal structures will not be released,for example 
memory used by the page cache will not be released; default size of 
cache is 1000 pages, if cache is full, it can take up 32MB if all 
pages are 32K or  4MB if page size is 4K.

If you really want to release all the memory used by a derby database 
then you need to shutdown the database. If you are frequently 
connecting back to the database,  shutting down the database is not a
good idea. It will impact the performance of u'r application .
First Connection that comes after the shutdown will
need to boot the database and also , it will need to reread the
data from the disk into the cache if your application is reading the 
same data that was in the cache before the shutdown.


Thanks
-suresht


Amit Modi wrote:
> Hello,
>  I am using derby for my desktop application. We have our complete 
> application in java and
> one problem which we are facing is, after doing login and logout 
> operation for five to six time
> it shows out of memory exception. When I used some profiler, I found out 
> that the maximum memory is getting
> used in execute() method of derby. Though after each logout I close the 
> database and before closing it I close all the statements and
> PreparedStatements create during the login.
> I think there are live pointer remaining after the database get closed 
> pointing to some raw data and result sets.
> Can anyone please let me know whatz the best practice to make all the 
> pointer point to null, created internally to database.
> 
> Thanks in Advance.
> 
> Regards:
> Amit Modi
>