You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by yves pielusenet <yv...@free.fr> on 2006/05/31 15:56:06 UTC

[MEMORY]Free memory

Hello,
I developpe an application which create several derby databases. It may
be 2 ddatabase or 100. In my application, I have a class which create
those databases and connexions.
Here the constructor method :
-----------------------------------------------------------------------
DBGenConnection(String purl, String pdbname, boolean cancreatedb,
boolean autocommit, String alterTableCreateIndex){
        this.alterTableCreateIndex = alterTableCreateIndex;

        String url = "jdbc:derby:"+purl+pdbname+";create="+cancreatedb;
        url = System.getProperty("db_url", url);

        try{
            String driver = "org.apache.derby.jdbc.EmbeddedDriver";
            String passwd = System.getProperty("db_passwd", "");
            String user = "";
            user = System.getProperty("db_user", user);

            Class.forName(driver);
            // create the conenxion
            con = DriverManager.getConnection(url, user, passwd);
            con.setAutoCommit(false);
        }
        catch(Exception e){
            System.err.println("erreur : "+e);
    }
}
----------------------------------------------------------------------
When I finish to deal with one database, I close it before create the
next one. when I close a database I only do 'myConnection.commit()' and
'myConnection.close()' and that's all.
I run a java memerory profiler and it seems that when I close a databse,
memory is not completly free. 
Is there something to do closing a database to free all memory use by
this database ?

thanks

-- 
yves piel


Re: [MEMORY]Free memory

Posted by yves pielusenet <yv...@free.fr>.
Le jeudi 01 juin 2006 à 10:15 +0200, John Embretsen a écrit :
> yves pielusenet wrote:
> 
> > Here is two screenshoots of jmp (Java Memory Profiler). My application
> > create 10 derby database (2 by 2).
> > So before when I didn't shutdown database (look at the Heap size  =
> > 63.5MB) : 
> > http://narma.free.fr/depot/sansShutdown.png
> > 
> > And now when I shutdown databases (I draw red arrow each times 2
> > databases are shutdown (at the same time)):
> > http://narma.free.fr/depot/avecShutdown.png
> > 
> > It is the same application and the second screen shoot has been taken
> > more longer after then the first. So I save ~40M :c)
> 
> 
> Interesting graphs... I have not used JMP before (but similar tools); so 
> would you mind telling us what exactly the gray, pink and green colors 
> represent in your screenshots?
> 
> I am assuming that the x-axis represents time and that the y-axis 
> represents bytes (heap usage and/or capacity).
> 
> Also, which JVM version/vendor are you using, and which version of Derby?
> 
> 
* So in pink it is the Heap memory of java (the memory allocated by
java).
* Into grey it is momory really used
* Into green it is momory used by object from derby package. Here
options I use for jmp :
-Xrunjmp:nomethods,nomonitors,noobjects,filter=org.apache.derby
and when my graphique user interface is shown I active objects and
monitor profiling.

* Here the java I use :
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

* And my derby package is : db-derby-10.1.2.1-bin

-- 
yves piel


Re: [MEMORY]Free memory

Posted by John Embretsen <Jo...@Sun.COM>.
yves pielusenet wrote:

> Here is two screenshoots of jmp (Java Memory Profiler). My application
> create 10 derby database (2 by 2).
> So before when I didn't shutdown database (look at the Heap size  =
> 63.5MB) : 
> http://narma.free.fr/depot/sansShutdown.png
> 
> And now when I shutdown databases (I draw red arrow each times 2
> databases are shutdown (at the same time)):
> http://narma.free.fr/depot/avecShutdown.png
> 
> It is the same application and the second screen shoot has been taken
> more longer after then the first. So I save ~40M :c)


Interesting graphs... I have not used JMP before (but similar tools); so 
would you mind telling us what exactly the gray, pink and green colors 
represent in your screenshots?

I am assuming that the x-axis represents time and that the y-axis 
represents bytes (heap usage and/or capacity).

Also, which JVM version/vendor are you using, and which version of Derby?


-- 
John

Re: [MEMORY]Free memory

Posted by yves pielusenet <yv...@free.fr>.
Here is two screenshoots of jmp (Java Memory Profiler). My application
create 10 derby database (2 by 2).
So before when I didn't shutdown database (look at the Heap size  =
63.5MB) : 
http://narma.free.fr/depot/sansShutdown.png

And now when I shutdown databases (I draw red arrow each times 2
databases are shutdown (at the same time)):
http://narma.free.fr/depot/avecShutdown.png

It is the same application and the second screen shoot has been taken
more longer after then the first. So I save ~40M :c)

Le mercredi 31 mai 2006 à 16:43 +0200, yves pielusenet a écrit :
> Yes :) that was it !
> thank you very much bryan :)
> 
> Le mercredi 31 mai 2006 à 07:07 -0700, Bryan Pendleton a écrit :
> > > Is there something to do closing a database to free all memory use by
> > > this database ?
> > 
> > In addition to committing and closing your connections, you can also
> > shut down the database:
> > http://db.apache.org/derby/docs/10.1/devguide/tdevdvlp40464.html
> > 
> > thanks,
> > 
> > bryan
> > 
> > 
> 
> 


Re: [MEMORY]Free memory

Posted by yves pielusenet <yv...@free.fr>.
Yes :) that was it !
thank you very much bryan :)

Le mercredi 31 mai 2006 à 07:07 -0700, Bryan Pendleton a écrit :
> > Is there something to do closing a database to free all memory use by
> > this database ?
> 
> In addition to committing and closing your connections, you can also
> shut down the database:
> http://db.apache.org/derby/docs/10.1/devguide/tdevdvlp40464.html
> 
> thanks,
> 
> bryan
> 
> 


Re: [MEMORY]Free memory

Posted by Kristian Waagan <Kr...@Sun.COM>.
derby@segel.com wrote:

>Silly question...
>
>If the database is being opened as an embedded database, that would imply
>that you can only have one user or is it one connection to the database?
>  
>
Hello,

You can have multiple users and connections to an embedded Derby database.
You can also have your application use Derby embedded, and at the same 
time start the network server in the same JVM to have remote/external 
clients connect to the database as well.



--
Kristian

>Assuming that there can only be one connection, when its closed, shouldn't
>derby stop running?
>
>
>  
>
>>-----Original Message-----
>>From: Bryan Pendleton [mailto:bpendleton@amberpoint.com]
>>Sent: Wednesday, May 31, 2006 9:07 AM
>>To: Derby Discussion
>>Subject: Re: [MEMORY]Free memory
>>
>>    
>>
>>>Is there something to do closing a database to free all memory use by
>>>this database ?
>>>      
>>>
>>In addition to committing and closing your connections, you can also
>>shut down the database:
>>http://db.apache.org/derby/docs/10.1/devguide/tdevdvlp40464.html
>>
>>thanks,
>>
>>bryan
>>    
>>
>
>
>
>  
>


RE: [MEMORY]Free memory

Posted by de...@segel.com.
Silly question...

If the database is being opened as an embedded database, that would imply
that you can only have one user or is it one connection to the database?

Assuming that there can only be one connection, when its closed, shouldn't
derby stop running?


> -----Original Message-----
> From: Bryan Pendleton [mailto:bpendleton@amberpoint.com]
> Sent: Wednesday, May 31, 2006 9:07 AM
> To: Derby Discussion
> Subject: Re: [MEMORY]Free memory
> 
> > Is there something to do closing a database to free all memory use by
> > this database ?
> 
> In addition to committing and closing your connections, you can also
> shut down the database:
> http://db.apache.org/derby/docs/10.1/devguide/tdevdvlp40464.html
> 
> thanks,
> 
> bryan




Re: [MEMORY]Free memory

Posted by Bryan Pendleton <bp...@amberpoint.com>.
> Is there something to do closing a database to free all memory use by
> this database ?

In addition to committing and closing your connections, you can also
shut down the database:
http://db.apache.org/derby/docs/10.1/devguide/tdevdvlp40464.html

thanks,

bryan