Each time a new bouncycastleprovider leads to a memory leak

Source: Internet
Author: User
problem Reason


The production server's memory has been elevated until it is down. The memory analysis concludes that memory leaks.
Download the dump file, after the parse stack log, as shown in the following figure:




The class "Javax.crypto.JceSecurity", Loaded by "<system class Loader>", occupies 2,522,379,928 (95.73%) bytes. The memory is accumulated in one instance of ' java.lang.object[' Loaded by ' <system class loader> '. Keywords

java.lang.object[]

javax.crypto.JceSecurity


 





is bouncycastleprovider this class inside the method, all is static, new one more than one, GC does not recycle, slowly on the downtime.



The dump code is as follows:
Solution



private static Org.bouncycastle.jce.provider.BouncyCastleProvider Bouncycastleprovider = null;


   public static synchronized Org.bouncycastle.jce.provider.BouncyCastleProvider getinstance () {

       if ( Bouncycastleprovider = = null) {

           Bouncycastleprovider = new Org.bouncycastle.jce.provider.BouncyCastleProvider ();

       return

       bouncycastleprovider;

   }


Keypairgenerator Keypairgen = keypairgenerator.getinstance ("RSA", getinstance ());


 


Memory leak analysis tool See also: http://blog.csdn.net/shenhaiwen/article/details/54670234


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.