Results 1 to 5 of 5

Thread: Tomcat Memory leaks with spring saml

  1. #1
    Join Date
    Aug 2012
    Location
    milano segrate
    Posts
    16

    Default Tomcat Memory leaks with spring saml

    I noticed that after using "undeploy" with the tomcat manager,
    a webapp i have integrated with spring saml module can't be cleanly destroyed.
    Im using tomcat Apache Tomcat/7.0.30 and jvm 1.7.0_07-b10.
    maybe it 's just something trivial, maybe with some @PreDestroy ad hoc can be fixed?

    i copy here the log, any idea ? thanks

    Code:
    SEVERE: The web application [/XXXXXXX] appears to have started a thread named [Timer-3] but has failed to stop it. This is very likely to create a memory leak.
    Feb 11, 2013 2:51:05 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
    SEVERE: The web application [/XXXXXXX] appears to have started a thread named [Timer-4] but has failed to stop it. This is very likely to create a memory leak.
    Feb 11, 2013 2:51:05 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
    SEVERE: The web application [/XXXXXXX] appears to have started a thread named [Timer-5] but has failed to stop it. This is very likely to create a memory leak.
    Feb 11, 2013 2:51:05 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
    SEVERE: The web application [/XXXXXXX] created a ThreadLocal with key of type [org.apache.xml.security.algorithms.SignatureAlgorithm$1] (value [org.apache.xml.security.algorithms.SignatureAlgorithm$1@b7ed90]) and a value of type [java.util.HashMap] (value [{http://www.w3.org/2000/09/xmldsig#rsa-sha1=org.apache.xml.security.algorithms.implementations.SignatureBaseRSA$SignatureRSASHA1@14d9abe}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    Feb 11, 2013 2:51:05 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
    SEVERE: The web application [/XXXXXXX] created a ThreadLocal with key of type [org.apache.xml.security.algorithms.MessageDigestAlgorithm$1] (value [org.apache.xml.security.algorithms.MessageDigestAlgorithm$1@1ea5dbf]) and a value of type [java.util.HashMap] (value [{http://www.w3.org/2000/09/xmldsig#sha1=SHA-1 Message Digest from SUN,
    }]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    Feb 11, 2013 2:51:05 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
    SEVERE: The web application [/XXXXXXX] created a ThreadLocal with key of type [org.apache.xml.security.utils.UnsyncBufferedOutputStream$1] (value [org.apache.xml.security.utils.UnsyncBufferedOutputStream$1@1b0e313]) and a value of type [byte[]] (value [[B@c2ca7]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    Feb 11, 2013 2:51:05 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
    SEVERE: The web application [/XXXXXXX] created a ThreadLocal with key of type [org.apache.xml.security.algorithms.SignatureAlgorithm$3] (value [org.apache.xml.security.algorithms.SignatureAlgorithm$3@147c583]) and a value of type [java.util.HashMap] (value [{http://www.w3.org/2000/09/xmldsig#rsa-sha1=Sun RSA private CRT key, 2048 bits
    modulus: 25220458843138597911636082222645174059800957638701512662873786633177145664977889972172064986486859345691610073852977080365156996616568380915745994494529219065967204508834645475880129482050807024112619269770688101633332928955828696710719079035175434992299707374136938565114383678184880653896234574453007308312485938127381162672227866211680767579104255079195096360770451186558497458040924872967071949604129137120883027621946269058128272082916327819876311961606282157130087210765164343667753562960183423936106413981140969589469744159507786182724438781175401447459676120550183022911336655012739901168557102114904963320883
    public exponent: 65537
    private exponent: 13196899386724322721267927547204952225960209352030013179546374796092952931765060665207388568008817424383209244589165555593974836885606290900463515101406694072496655999228931707346342986831382658313533616403653006230249876141450379118676310745888142456794388894537101701534515761722295989503083330969024819933001872553564520052642014949299800435233734768042558021776764320692577814467635819812403369590483557144383071336687635502871787005973336377100699424732138991811706325596092045761272450033801337270124221617075689447477817922371380829769945906078698857655281059029590106985047020411368792034566847958569692249665
    prime p: 173818853026318258255347631959543211406042542097174207361195959762698347155450392604462146143429759160555177278716021487990330707096986466764452874687788606305668579706147141485204970472872473358323505808739336519588371462954635285489062203335842394805824860599393016287455757411051972606072767520612458352979
    prime q: 145096221750582591151542469953603537677121483728280387649951483022158069659409431430014823935679085639112635979001467120725282669655560227341336292217820144987548206756941431527997734940136943034781971767937472473860209392716998171004573065557761396159693421160883995441452221874866812778813978700647098588577
    prime exponent p: 4858875730415109771942518909164031971189861255810048489947830970066731342429240265062097009853415914401591235097849327341780762857648034043555207995911145257671007797452760474249591923742349683269735609527602186610401704687930357553991820750282485729958209021134443228079084297069551761818900927686070825681
    prime exponent q: 90960499727217995292142184995404143391741095243547915324141426674479519843093771309369654415023196568090432110064166450325743297416706470243050514453959452779550758725741775093882645528717004205014225705871661146963497000164454733291467177295888230483864140995085508227597609529409387109839820481805484619553
    crt coefficient: 103095279387637747289752690589814527091762536149098639755503972102073487811260148101767109907566425529455984422002092537272381544678305950897625210857406064185092296730838183063072386531399521370287157950867936448997321027963950435701717901616401461861958946946244201177503530074411072248445781551169929080856}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    Feb 11, 2013 2:51:05 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
    SEVERE: The web application [/XXXXXXX] created a ThreadLocal with key of type [org.apache.xml.security.utils.UnsyncByteArrayOutputStream$1] (value [org.apache.xml.security.utils.UnsyncByteArrayOutputStream$1@f8506e]) and a value of type [byte[]] (value [[B@687290]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    Feb 11, 2013 2:51:05 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
    SEVERE: The web application [/XXXXXXX] created a ThreadLocal with key of type [org.apache.xml.security.algorithms.SignatureAlgorithm$1] (value [org.apache.xml.security.algorithms.SignatureAlgorithm$1@b7ed90]) and a value of type [java.util.HashMap] (value [{http://www.w3.org/2000/09/xmldsig#rsa-sha1=org.apache.xml.security.algorithms.implementations.SignatureBaseRSA$SignatureRSASHA1@1397841}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    Feb 11, 2013 2:51:05 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
    SEVERE: The web application [/XXXXXXX] created a ThreadLocal with key of type [org.apache.xml.security.algorithms.MessageDigestAlgorithm$1] (value [org.apache.xml.security.algorithms.MessageDigestAlgorithm$1@1ea5dbf]) and a value of type [java.util.HashMap] (value [{http://www.w3.org/2000/09/xmldsig#sha1=SHA-1 Message Digest from SUN,
    }]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    Feb 11, 2013 2:51:05 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
    SEVERE: The web application [/XXXXXXX] created a ThreadLocal with key of type [org.apache.xml.security.utils.UnsyncBufferedOutputStream$1] (value [org.apache.xml.security.utils.UnsyncBufferedOutputStream$1@1b0e313]) and a value of type [byte[]] (value [[B@6264b]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    Feb 11, 2013 2:51:05 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
    SEVERE: The web application [/XXXXXXX] created a ThreadLocal with key of type [org.apache.xml.security.algorithms.SignatureAlgorithm$3] (value [org.apache.xml.security.algorithms.SignatureAlgorithm$3@147c583]) and a value of type [java.util.HashMap] (value [{http://www.w3.org/2000/09/xmldsig#rsa-sha1=Sun RSA private CRT key, 2048 bits
    modulus:
     .........................

  2. #2
    Join Date
    Feb 2009
    Location
    Helsinki
    Posts
    151

    Default

    Hi,

    Thanks for reporting this. No idea so far, but I'll try to find a moment and will look into it.

    Vladimír Schäfer

  3. #3
    Join Date
    Aug 2012
    Location
    milano segrate
    Posts
    16

    Default

    This seems to solve the problem.

    public class ExtendedMetadataDelegate extends AbstractMetadataDelegate implements ExtendedMetadataProvider {

    @PreDestroy
    public void dest(){
    if (getDelegate() instanceof AbstractMetadataProvider) {
    AbstractMetadataProvider provider = (AbstractMetadataProvider) getDelegate();
    provider.destroy();
    } else {
    System.out.println("Cannot stop provider");
    }
    }

    let me know if this is correct.
    Last edited by aleale; Feb 20th, 2013 at 05:57 AM.

  4. #4
    Join Date
    Feb 2009
    Location
    Helsinki
    Posts
    151

    Default

    Hi,

    You're right, the cleanup of metadata was broken. The correct place to destroy it is in the MetadataManager's destroy() method though. I've just pushed an update.

    It's worth noting that Tomcat seems to have issues with correctly terminated threads. Some discussion related to usage of the OpenSAML library (internal of the SAML Extension) recommend to restart server between each redeploy for this reason.

    Cheers, Vladi

  5. #5
    Join Date
    Aug 2012
    Location
    milano segrate
    Posts
    16

    Default

    Quote Originally Posted by vsch View Post
    Hi,

    You're right, the cleanup of metadata was broken. The correct place to destroy it is in the MetadataManager's destroy() method though. I've just pushed an update.

    It's worth noting that Tomcat seems to have issues with correctly terminated threads. Some discussion related to usage of the OpenSAML library (internal of the SAML Extension) recommend to restart server between each redeploy for this reason.

    Cheers, Vladi

    Tried the module with the change on the metadata cleanup.
    I have observed that Tomcat7 complains at first, but auto-solve the problem in 15 minutes after the "Undeploying".

    Alessandro

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •