You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Balazs Michnay <sz...@yahoo.com> on 2007/05/22 14:07:37 UTC

Serious memory leak

Hi,

I have just downloaded NetBeans Profiler to see how my web-app performs and realized that it produces serious memory leaks... The interesting part is that I have nothing on my JSP but static struts tags (no dynamic content at all) and it turned out that the leaks are not made by my application, but made by either struts (???) or Tomcat (???) or Java itself, I don't know what...
What I discovered was that a simple page reload leads to eating up my memory and - according to the profiler - the memory leak is produced by the constructor of java.util.zip.InflaterInputStream allocating more and more byte[] objects that cannot be garbage-collected. This class deals with reading jar files. If I take a look at the source code I can clearly see that it really allocates memory for byte[]:

public InflaterInputStream(InputStream in, Inflater inf, int size) {
    super(in);
        if (in == null || inf == null) {
            throw new NullPointerException();
        } else if (size <= 0) {
            throw new IllegalArgumentException("buffer size <= 0");
        }
    this.inf = inf;
    buf = new byte[size];
}

After browsing through about 80-100 pages I get an OutOfMemory error...

Interesting, huh?

Where should I ask this? On a Java list? Or does this have anything to do with Struts (probably not...)?
Any ideas why this happens are welcome...

Regards,

BM



       
____________________________________________________________________________________Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545469

Re: Serious memory leak

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Balazs,

Balazs Michnay wrote:
> I have just downloaded NetBeans Profiler to see how my web-app
> performs and realized that it produces serious memory leaks...

[snip]

> What I discovered was that
> a simple page reload leads to eating up my memory and - according to
> the profiler - the memory leak is produced by the constructor of
> java.util.zip.InflaterInputStream allocating more and more byte[]
> objects that cannot be garbage-collected.

Are you sure they cannot be garbage-collected? How do you know?

> This class deals with
> reading jar files.

Usually, JAR files are read to load class files. When class files are
read, their code needs to be read into memory (in byte arrays). It also
need to stay in memory in order to be executed. It's true, class loading
uses memory ;)

> After browsing through about 80-100 pages I get an OutOfMemory
> error...

Are you sure these facts are related? Class loading almost never causes
a problem unless you are loading millions of classes.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGUuwf9CaO5/Lv0PARAvHKAKDDPuJNP4WIl7xFaLTK/jGES62YcQCffXx9
NGZ9AClOPKuN7KUo1F/Is+U=
=oTIF
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Serious memory leak

Posted by Roger Varley <ro...@googlemail.com>.
On 22/05/07, Balazs Michnay <sz...@yahoo.com> wrote:
> Hi,
>
> I have just downloaded NetBeans Profiler to see how my web-app performs and realized that it produces serious memory leaks... The interesting part is that I have nothing on my JSP but static struts tags (no dynamic content at all) and it turned out that the leaks are not made by my application, but made by either struts (???) or Tomcat (???) or Java itself, I don't know what...

I don't want to be seen to be teaching my grannie to suck eggs, but
are you doing your profiling with a clean start of Netbeans and
Tomcat? I've just been indulging in a fairly rapid cycle of develop,
deploy in-situ, test using Netbeans and the embedded Tomcat, and have
crashed with an OOM error. So something in Netbeans or, more likely,
Tomcat is holding resource when you re-deploy in-situ.

Regards
Roger

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Serious memory leak

Posted by Torsten Römer <to...@luniks.net>.
You could also try to run jmap -histo <PID> when you get the
OutOfMemoryError; you'll probably see the same as in the NetBeans
profiler but maybe it helps to reveal the "memory eater" anyway.

Torsten

Balazs Michnay wrote:
> Hi,
> 
> I have just downloaded NetBeans Profiler to see how my web-app performs and realized that it produces serious memory leaks... The interesting part is that I have nothing on my JSP but static struts tags (no dynamic content at all) and it turned out that the leaks are not made by my application, but made by either struts (???) or Tomcat (???) or Java itself, I don't know what...
> What I discovered was that a simple page reload leads to eating up my memory and - according to the profiler - the memory leak is produced by the constructor of java.util.zip.InflaterInputStream allocating more and more byte[] objects that cannot be garbage-collected. This class deals with reading jar files. If I take a look at the source code I can clearly see that it really allocates memory for byte[]:
> 
> public InflaterInputStream(InputStream in, Inflater inf, int size) {
>     super(in);
>         if (in == null || inf == null) {
>             throw new NullPointerException();
>         } else if (size <= 0) {
>             throw new IllegalArgumentException("buffer size <= 0");
>         }
>     this.inf = inf;
>     buf = new byte[size];
> }
> 
> After browsing through about 80-100 pages I get an OutOfMemory error...
> 
> Interesting, huh?
> 
> Where should I ask this? On a Java list? Or does this have anything to do with Struts (probably not...)?
> Any ideas why this happens are welcome...
> 
> Regards,
> 
> BM
> 
> 
> 
>        
> ____________________________________________________________________________________Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
> http://answers.yahoo.com/dir/?link=list&sid=396545469

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Serious memory leak

Posted by Guillaume Carré <gu...@gmail.com>.
2007/5/22, Balazs Michnay <sz...@yahoo.com>:
> Hi,
>
> I have just downloaded NetBeans Profiler to see how my web-app performs and realized that it produces serious memory leaks... The interesting part is that I have nothing on my JSP but static struts tags (no dynamic content at all) and it turned out that the leaks are not made by my application, but made by either struts (???) or Tomcat (???) or Java itself, I don't know what...
> What I discovered was that a simple page reload leads to eating up my memory and - according to the profiler - the memory leak is produced by the constructor of java.util.zip.InflaterInputStream allocating more and more byte[] objects that cannot be garbage-collected. This class deals with reading jar files. If I take a look at the source code I can clearly see that it really allocates memory for byte[]:

do you have a stack strace? to see what objects call InflaterInputStream
-- 
Guillaume Carré

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org