cool hit counter JVM memory management_Intefrankly

JVM memory management


One: First, understand two concepts: physical memory and virtual memory

  •    Physical memory: commonly referred to as RAM (random memory), has a storage unit register that stores the intermediate results of instructions executed by a computing unit. Physical memory is real, e.g., memory sticks
  •    Virtual memory: A logical piece of memory that is virtualized using disk space. The disk used as virtual memory is called swap space. Virtual memory ensures that multiple threads can share the same piece of physical memory when executing simultaneously. But it's only shared spatially, not logically, and the mutual brackets are not directly accessible.

2: What is Kernel? What is User Space?

  • -   The kernel is the memory, or system space, that the operating system needs to run.
  • User space is a portion of space provided for use by user threads.

   Kernel space is used to store system process data; user space is used to store user process data. If not divided, it will result in data confusion and affect the proper functioning of the system. Separate storage ensures that the operating system and user processes do not affect each other, ensuring system stability and also facilitating management. More importantly by isolating user data from system data, it is possible to control access to data in various parts. This guarantees that user processes cannot modify system processes and prevents user processes from maliciously modifying system processes and affecting the use of system processes.

III: Internal overflows and memory leaks

  1.   Internal overflow: out of memory is thrown when the program requests memory again if there is not enough memory space   
  2. memory leak: Objects that should be garbage collected, And it wasn't recycled., Resulting in wasted memory space, That's a memory overflow.。 Memory leaks can lead to memory overflows。
  •    Causes of memory overflows.
      •      too much data to load at one time.
      •    A reference to an object exists in the collection, but is used up and not garbage collected, creating a memory leak and resulting in a memory overflow.
      •    Dead loops in the code or too many duplicate objects
    •   Solutions for memory overflow.
      •    Modify the boot memory of the VM to increase the memory space (-Xms -Xmx)
      • Check the logs for the cause of the memory overflow and then find a solution
      • Check the code for possible memory overflows and make changes  

IV: JVM Memory Allocation Strategy

  •    Static memory distribution: the size of the space needed for the object can be determined at compile time, and the memory space is allocated at once during the compilation process.
  • Heap memory distribution: The amount of space needed is not known during compilation, Only when the program runs to the code that responds, Only then do we know the size of the space, This time for memory space allocation。
  • Stack memory allocation: Dynamic Storage Distribution, Allocate memory space at program runtime, is a first-in, last-out allocation strategy

Recommended>>
1、Opinion Deep Learning Keep Up First
2、Python Learning ObjectOriented Medium
3、PHP vs Nodejs
4、Dummy variables in Python dummyvariables
5、2016 the year when deep learning led the way

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号