Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory blocked out when using embedded Jetty as application server

Tags:

java

memory

jetty

I am using embedded jetty as a Java application server, with maximum JVM memory set to 800MB. I created a method to deploy and un-deploy web archives. Every time I deploy a war with a basic hello world application the embedded application server uses approximately 200MB additional memory which causes an out of memory after I add the 4th web app. Is this the expected behaviour for embedded Jetty when used as an application server?

@ManagedOperation
public boolean deployWebApp(String context, String pathToWar){
    boolean success = false;
    WebAppContext webctx = null;
    try{
        webctx = addWebApp(context, pathToWar);
        webctx.getTempDirectory();
        webctx.start();
        success = webctx.isRunning();
    } catch (Exception e) {
        e.printStackTrace();
        logger.log(Level.SEVERE, "Failed to startup webapp with webappcontext: ", webapps.get(context).getContextPath());           
    }
    return success;     
}
like image 267
ronly2008 Avatar asked Mar 24 '26 13:03

ronly2008


1 Answers

No, I use embedded Jetty and it doesn't use anything like that amount of memory.

The best thing to do is create a heap dump and then use a tool like the Eclipse Memory Analyzer to analyse the heap and see what it is about the web apps that are consuming so much memory.

like image 72
Dan Gravell Avatar answered Mar 26 '26 02:03

Dan Gravell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!