`

Memory usage of Java

    博客分类:
  • JAVA
 
阅读更多

用JDK自带的api计算size,每次都会有个多余的12,看了这些文档终于知道了

 

1:Memory usage of Java Strings and string-related objects

http://www.javamex.com/tutorials/memory/string_memory_usage.shtml

 

 

2:Memory usage of Java objects: general guide

http://www.javamex.com/tutorials/memory/object_memory_usage.shtml

 

 

How to calculate the memory usage of a Java array

http://www.javamex.com/tutorials/memory/array_memory_usage.shtml

 

 

4:Memory usage of Java Strings and string-related objects

http://www.javamex.com/tutorials/memory/string_buffer_memory_usage.shtml

分享到:
评论
2 楼 vavi 2012-10-08  
啊 明白我错在哪里了 
1 楼 vavi 2012-10-07  
请教个问题,String内存大小是如何计算的?
multiply the number of characters of the String by two;
add 38;
if the result is not a multiple of 8, round up to the next multiple of 8;
the result is generally the minimum number of bytes taken up on the heap by the String.
我只能这样算: ojbect head  为 8 bytes
            3个 int       为 3*4 = 12 bytes
            1个char[]     为 12
不考虑char[]大小的话,为 8+12+12=32 bytes(不是38个字节), 还有6个字节那里去了??

相关推荐

    Android代码-查看手机应用的CPU和内存资源的使用情况

    AnotherMonitor monitors and records the CPU and memory usage of Android devices. Download ready-to-use app The app is released on Google Play: ...

    http://elinux.org/Android_Memory_Usage

    标题中的“Android_Memory_Usage”表明我们即将探讨的是关于Android系统内存使用的主题。这个话题在Android应用开发中至关重要,因为它涉及到应用性能、稳定性和用户体验。Android系统的内存管理机制是开发者必须...

    Problem Solving in Data Structures & Algorithms Using Java 2nd Edition

    Problem Solving in Data Structures & Algorithms” is a series of books about the usage of Data Structures and Algorithms in computer programming. The book is easy to follow and is written for ...

    client_java,用于jvm应用程序的prometheus工具库.zip

    Gauge memoryUsage = Gauge.build().name("memory_usage").help("Current memory usage in bytes").register(); // 设置值 memoryUsage.set(Runtime.getRuntime().totalMemory()); ``` 3. **创建Summary**:...

    Mastering Lambdas- Java Programming in a Multicore World

    - **Memory Usage**: Streams are lazy, meaning they do not execute until a terminal operation is called. This laziness helps reduce memory consumption by only computing values as needed. - **...

    javacv-platform-1.3.3-src

    JavaCV uses wrappers from the JavaCPP Presets of commonly used libraries by researchers in the field of computer vision (OpenCV, FFmpeg, libdc1394, PGR FlyCapture, OpenKinect, librealsense, CL PS3 Eye...

    Object-relative Addressing - Compressed Pointers in 64-bit Java Virtual Machines (P107_134)-计算机科学

    much memory as 32-bit address spaces, resulting in increased memory usage.This paper reduces the memory usage of 64-bit pointers in the context of Java virtual machines through pointer compression, ...

    亚信java笔试题-FE:前端资源收集

    亚信java笔试题 ##说说你对闭包的理解 ##Talk about your understanding of closures 使用闭包主要是为了设计私有的方法和变量。闭包的优点是可以避免全局变量的污染,缺点是闭包会常驻内存,会增大内存使用量,使用...

    AKKA (java) 精讲

    ##### 2.7 Akka and the Java Memory Model Akka 的设计考虑到了 Java 内存模型的影响,确保了 Actor 的线程安全性和内存一致性。 ##### 2.8 Message Delivery Reliability Akka 支持可靠的消息传递机制,确保消息...

    hive on tez 常见报错问题收集

    3. 错误三:Container killed due to excessive memory usage 如果Tez作业的Container使用了过多内存导致被NodeManager杀死,可以调整`tez.am.resource.memory.mb`以增大应用程序管理器的内存大小,例如设置为4096...

    Efficient MIDP Programming

    Networking operations can consume significant resources, especially in terms of CPU and memory usage. - **Asynchronous Networking**: Use asynchronous networking APIs to offload network operations ...

    关于jsp的简介以及优点和缺点

    JSP's performance can be impacted due to the need to keep class files in memory, which may lead to higher resource usage, especially in terms of memory and disk space for storing .java and .class ...

    JProfiler Helper

    It provides developers with a detailed analysis of their Java programs' performance, enabling them to identify bottlenecks, optimize memory usage, and enhance overall application efficiency....

    jdk1.8_win64.rar

    4. **Date and Time API**: Java 8 overhauls the date and time handling with the introduction of the `java.time` package, replacing the older `java.util.Date` and `java.util.Calendar`. The new API is ...

    C Programming

    - **scanf() and printf()**: Usage of these functions to read user input and display output, respectively. - **Punctuation**: Importance of punctuation marks like semicolons and curly braces in C ...

    clucene源码

    Memory in CLucene has been a bit of a difficult thing to manage because of the unclear specification about who owns what memory. This was mostly a result of CLucene's java-esque coding style that was ...

    操作系统(内存管理)

    /* Begin searching at the start of managed memory */ current_location = managed_memory_start; /* Keep going until we have searched all allocated space */ while(current_location != last_valid_...

    Professional Hadoop

    Configure storage, UE, and in-memory computing Integrate Hadoop with other programs including Kafka and Storm Master the fundamentals of Apache Big Top and Ignite Build robust data security with ...

Global site tag (gtag.js) - Google Analytics