Getting Started with Java--runtime class

Source: Internet
Author: User
Getting Started with Java--runtime class Know the runtime class

The runtime class represents the runtime's action class, a class that encapsulates the JVM process, each of which corresponds to an instance of the runtime class that is instantiated by the JVM runtime. The methods for obtaining instances of the runtime class are:

Runtime Run=runtime.getruntime ();

You can get some information about the system through the runtime instance.

Package Sep26;public class RuntimeDemo01 {public static void main (string[] args) {Runtime run=runtime.getruntime (); System.out.println ("JVM max Memory:" +run.maxmemory ());//Instantiate Runtime class System.out.println ("JVM Free Memory:" +run.freememory ());// Maximum memory string str= "Guo Congcong" + "\ n" + "is a good man!" "; for (int i=1;i<1000;i++) {str+=i;} Generates multiple garbage System.out.println ("Idle memory after operation of STR:" +run.freememory ()); Run.gc ();//garbage collection frees up space System.out.println (" Free memory after cleaning up garbage: "+run.freememory ());}}
JVM Max Memory: 954728448JVM free Memory: 63120600 free memory after operation of STR: 57416352 free memory after garbage cleanup: 63632776
  

Getting Started with Java--runtime class

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.