Java garbage collection for the use of skills

  Refuse collection (Garbage Collector, GC) is a modern virtual machine software technology an important component of its design in the virtual machine running on a great impact on application performance.    Java Virtual Machine (JVM). Net framework has been providing this function.    Below we briefly talk about Java Virtual Machine in the refuse collection Principle. 

  Java memory management actually is the object management, including the distribution and release objects. 

  For programmers, the object using the new keyword distribution; release object, as long as the object of all quoted assignment will be null.    For GC, when programmers to create objects, GC began monitoring the address of this object, the size and use.    Normally, a directed graph GC way to record and manage the reactor (heap), all objects.    In this way identify the object is "up", which object is "not up to."    When GC identify targets for "up to", it is incumbent upon the recovery of these GC memory space. 

  GC in the JVM is usually by one or a group of the process to achieve, and it is also the same as occupiers and users heap space occupied when running CPU.    When running GC process, the application to stop running.    Therefore, when GC longer running time, the user can feel Java programs standstill, the other hand, if the GC running time is too short, it may be targets of the recovery is too low, which means that there are a lot of recovery should not be the object of recovery, still occupy large amounts of memory.    Therefore, in the design of the GC time, we must pause and recovery time between weigh. 

  According to the working principle of GC, we can pass some techniques and ways to GC operation more efficient, more in line with application requirements. 

  The following are some of the procedures designed some suggestions. 

  1.    Is the most basic recommendations as soon as possible the release of useless object. 

  Most programmers in the use of temporary variables, the variables are used to withdraw from activities in the domain (scope), automatically set to null. 

  2.    Minimise use finalize function.    Finalize function is provided to the Java programmers to release a target of opportunity or resources.    However, it would increase the workload of GC, and therefore minimize the use of resources finalize modalities recovery. 

  3.    If you need the use of regular use of picture, you can use the soft application types.    It can be preserved as far as possible picture in memory for the procedure call, without incurring OutOfMemory. 

  4.    Attention to the aggregate data types, including arrays, trees, maps, data structures such as linked list for such objects, GC recovery generally less efficient.    If the program permits, as soon as possible without the application of object Fu null.    This will speed up the GC work.    Therefore, if necessary, procedures used in the data structure must be as easy as possible. 

  5.    When the wait for certain procedures, programmers can manually System.gc (), notify the GC running, but does not guarantee that the Java language specification will be the implementation of GC. 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Tags: ,

Releated Java Articles

Comments

Leave a Reply