Google-perftools analyzing Java out-of-heap memory

Source: Internet
Author: User

 Google-perftools analyzing Java out-of-heap memoryCategory: J2se2011-08-25 21:48 3358 People read Comments (4) favorite reports javahbasehtml tool OS

Translated from: http://koven2049.iteye.com/blog/1142768, all rights attributed to the original author

HBase discovery, which runs on the line recently, allocates 16g of memory, but actually uses 22g, and the out-of-heap memory reaches 6g. It feels very strange. Out-of-heap memory is difficult to see with general tools and can be tracked by Google-perftools:

Http://code.google.com/p/google-perftools/downloads/list
The idea is that when a Java application runs, it's libtcmalloc.so when you call malloc, so you can do some statistics.
    • Download Http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-beta.tar.gz,configure;make;sudo make Install
    • Download http://google-perftools.googlecode.com/files/google-perftools-1.8.1.tar.gz, configure--prefix=/home/user/ Perftools;make;sudo make Install
    • Join before application launch: Export ld_preload=/home/hadoop/perftools/lib/libtcmalloc.so and Export heapprofile=/home/user/perftools/ Test
    • Modify Lc_config:sudo vi/etc/ld.so.conf.d/usr_local_lib.conf, add/usr/local/lib (the directory where the Libunwind Lib is located)
    • Execute sudo/sbin/ldconfig to make libunwind effective
    • Start the application and you will see a heap file such as Test_pid.xxxx.heap under/home/user/perftools/, using Bin/bin/pprof--text $JAVA _home/bin/java test_ Pid.xxxx.heap to view


See the following through Perftools:
  1. Total: 3263.2 MB
  2. 3145.2 96.4% 96.4% 3145.2 96.4% zcalloc
  3. 83.8 2.6% 99.0% 83.8 2.6% os::malloc
  4. 30.0 0.9% 99.9% 30.0 0.9% init
  5. 2.2 0.1% 99.9% 2.2 0.1% objectsynchronizer::omalloc
  6. 1.0 0.0% 100.0% 3144.1 96.4% java_java_util_zip_deflater_init
  7. 0.6 0.0% 100.0% 0.7 0.0% readcen

Visible calls to Java.util.zip.Deflater occupy the vast majority. Knowing that this deflater has a bug that cannot free memory, write btrace to see if it has entered the function:
  1. Import static com.sun.btrace.btraceutils.*;
  2. Import com.sun.btrace.annotations.*;
  3. Import Java.nio.ByteBuffer;
  4. Import Java.lang.Thread;
  5. @BTrace public class testregion1{
  6. @OnMethod (
  7. clazz="Java.util.zip.Deflater",
  8. method="Deflate"
  9. )
  10. public static void Tracecacheblock () {
  11. println ("deflate?");
  12. }
  13. }

I found that this line of code is constantly being called. What should be done?
Since Deflater is the code that gzip needs to use, look at the user-created table, discover that the compressor setting is GZ, try to adjust to Lzo, and find btrace Unable to enter the above code, and then view it through Perftools, the heap memory no longer applies, completely no longer applies ...
episode, the author of Perftools is an honest man, provided a zip version of the download, but do not provide installation files, why? In the Readme, the following paragraph is spoken:
  
    1. I don ' t know very much about what to install DLLs on Windows, so you ll
    2. There is a to figure out the that part for yourself.

Google-perftools analyzing Java out-of-heap memory

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.