tomp2p / TomP2P

A P2P-based high performance key-value pair storage library
http://tomp2p.net
Apache License 2.0
438 stars 122 forks source link

Memory leak in PeerBuilder / Peer when left to run alone #86

Closed ghost closed 9 years ago

ghost commented 9 years ago

The following code, when started up through the Maven exec plugin and left to run for 24 hours, goes from 137 MB resident size for the JVM to 188 MB. Only about a dozen other peers have contacted this peer; no information exchange ( put, send, direct ) took place. This peer never gets wrapped in a PeerDHT.

public final void doRun()  throws IOException  {

    Random rnd = new Random();
        try {
            peer = new PeerBuilder( new Number160( rnd ) ).ports( 4000 ).start();
            System.out.println("peer up and running : " + peer.peerAddress());

    } finally {

    }
}
ghost commented 9 years ago

Did another experiment. Started the above peer on a vanilla Ubuntu Server workstation, left it alone for 72 hours, without ever connecting to the peer. Memory usage is at 198 MB after 72 hours.

ghost commented 9 years ago

This is the aggregated allocation made by the JVM running the above code, and nothing but that ( except for maven and its exec:java plugin ) for 25 hours. IMHO this should, fairly quickly after launch, level out; alas, it doesn't. Where is the leak ?

aggregate_alloc_tomp2p_peer

tbocek commented 9 years ago

I'm running some tests now and checking with VisualVM the memory usage. I did not run it for too long, but I could not clearly observe a memory leak. After a GC, it goes down to ~6MB. I'm running it with -Xmx32M to see if it will fail with OutOfMemory Exception. The graph goes slightly up, so there may be a very slow leak.

I'll let my test run for a while, and post a new graph. screenshot from 2015-02-16 20 44 18

tbocek commented 9 years ago

Do you run the test with a high -Xmx? If so, can you set it to something lower. Java's GC does not kick in if there is plenty of memory available.

ghost commented 9 years ago

No, I don't set -Xms and -Xmx at all. GC kicks in about every 700 seconds on the completely idle Peer.

Fortuna audaces adiuvat - hos solos ?

On 16 February 2015 at 21:01, Thomas Bocek notifications@github.com wrote:

Do you run the test with a high -Xmx? If so, can you set it to something lower. Java's GC does not kick in if there is plenty of memory available.

— Reply to this email directly or view it on GitHub https://github.com/tomp2p/TomP2P/issues/86#issuecomment-74564473.

tbocek commented 9 years ago

After one hour and constantly putting a value, I could not observe a memory leak. I was running net.tomp2p.dht.TestSinglePeer screenshot from 2015-02-16 22 20 16

tbocek commented 9 years ago

Can you try with -Xmx32 to see if you get an OutOfMemoryException?

ghost commented 9 years ago

Running now. Will report back tomorrow.

Fortuna audaces adiuvat - hos solos ?

On 16 February 2015 at 22:30, Thomas Bocek notifications@github.com wrote:

Can you try with -Xmx32 to see if you get an OutOfMemoryException?

— Reply to this email directly or view it on GitHub https://github.com/tomp2p/TomP2P/issues/86#issuecomment-74575361.

tbocek commented 9 years ago

@exercitussolus any news on this issue?

ghost commented 9 years ago

Yes, sorry for not giving feedback earlier ( work overload here ).

It turns out that, as I made TomP2P run inside the Maven exec plugin, what I discovered is a real memory leak, very much so - though not one of TomP2P. It is a Maven exec plugin problem.

Eight days of continuously running TestSinglePeer outside of Maven exec did not produce an OutOfMemoryException, in fact memory usage remained constant as per your observation. I think you may consider this one resolved :-)

Fortuna audaces adiuvat - hos solos ?

On 9 April 2015 at 13:33, Thomas Bocek notifications@github.com wrote:

@exercitussolus https://github.com/exercitussolus any news on this issue?

— Reply to this email directly or view it on GitHub https://github.com/tomp2p/TomP2P/issues/86#issuecomment-91202841.

tbocek commented 9 years ago

Thanks for the test!