< prev index next >

src/java.base/share/classes/java/lang/Runtime.java

Print this page


   1 /*
   2  * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 622      * Note that the amount of memory required to hold an object of any
 623      * given type may be implementation-dependent.
 624      *
 625      * @return  the total amount of memory currently available for current
 626      *          and future objects, measured in bytes.
 627      */
 628     public native long totalMemory();
 629 
 630     /**
 631      * Returns the maximum amount of memory that the Java virtual machine
 632      * will attempt to use.  If there is no inherent limit then the value
 633      * {@link java.lang.Long#MAX_VALUE} will be returned.
 634      *
 635      * @return  the maximum amount of memory that the virtual machine will
 636      *          attempt to use, measured in bytes
 637      * @since 1.4
 638      */
 639     public native long maxMemory();
 640 
 641     /**
 642      * Runs the garbage collector in the Java Virtual Machine.
 643      * <p>
 644      * Calling this method suggests that the Java Virtual Machine
 645      * expend effort toward recycling unused objects in order to
 646      * make the memory they currently occupy available for reuse
 647      * by the Java Virtual Machine.
 648      * When control returns from the method call, the Java Virtual Machine
 649      * has made a best effort to reclaim space from all unused objects.
 650      * There is no guarantee that this effort will recycle any particular
 651      * number of unused objects, reclaim any particular amount of space, or
 652      * complete at any particular time, if at all, before the method returns or ever.
 653      * <p>
 654      * The name {@code gc} stands for "garbage
 655      * collector". The Java Virtual Machine performs this recycling
 656      * process automatically as needed, in a separate thread, even if the
 657      * {@code gc} method is not invoked explicitly.
 658      * <p>
 659      * The method {@link System#gc()} is the conventional and convenient
 660      * means of invoking this method.
 661      */
 662     public native void gc();
 663 
 664     /**
 665      * Runs the finalization methods of any objects pending finalization.
 666      * Calling this method suggests that the Java virtual machine expend
 667      * effort toward running the {@code finalize} methods of objects
 668      * that have been found to be discarded but whose {@code finalize}
 669      * methods have not yet been run. When control returns from the
 670      * method call, the virtual machine has made a best effort to
 671      * complete all outstanding finalizations.
 672      * <p>
 673      * The virtual machine performs the finalization process
 674      * automatically as needed, in a separate thread, if the
 675      * {@code runFinalization} method is not invoked explicitly.
 676      * <p>
 677      * The method {@link System#runFinalization()} is the conventional
 678      * and convenient means of invoking this method.
 679      *
 680      * @see     java.lang.Object#finalize()
 681      */
 682     public void runFinalization() {
 683         SharedSecrets.getJavaLangRefAccess().runFinalization();
 684     }


























 685 
 686     /**
 687      * Loads the native library specified by the filename argument.  The filename
 688      * argument must be an absolute path name.
 689      * (for example
 690      * {@code Runtime.getRuntime().load("/home/avh/lib/libX11.so");}).
 691      *
 692      * If the filename argument, when stripped of any platform-specific library
 693      * prefix, path, and file extension, indicates a library whose name is,
 694      * for example, L, and a native library called L is statically linked
 695      * with the VM, then the JNI_OnLoad_L function exported by the library
 696      * is invoked rather than attempting to load a dynamic library.
 697      * A filename matching the argument does not have to exist in the file
 698      * system.
 699      * See the <a href="{@docRoot}/../specs/jni/index.html"> JNI Specification</a>
 700      * for more details.
 701      *
 702      * Otherwise, the filename argument is mapped to a native library image in
 703      * an implementation-dependent manner.
 704      * <p>


   1 /*
   2  * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 622      * Note that the amount of memory required to hold an object of any
 623      * given type may be implementation-dependent.
 624      *
 625      * @return  the total amount of memory currently available for current
 626      *          and future objects, measured in bytes.
 627      */
 628     public native long totalMemory();
 629 
 630     /**
 631      * Returns the maximum amount of memory that the Java virtual machine
 632      * will attempt to use.  If there is no inherent limit then the value
 633      * {@link java.lang.Long#MAX_VALUE} will be returned.
 634      *
 635      * @return  the maximum amount of memory that the virtual machine will
 636      *          attempt to use, measured in bytes
 637      * @since 1.4
 638      */
 639     public native long maxMemory();
 640 
 641     /**
 642      * Runs the garbage collector.
 643      * Calling this method suggests that the Java virtual machine expend
 644      * effort toward recycling unused objects in order to make the memory
 645      * they currently occupy available for quick reuse. When control
 646      * returns from the method call, the virtual machine has made
 647      * its best effort to recycle all discarded objects.





 648      * <p>
 649      * The name {@code gc} stands for "garbage
 650      * collector". The virtual machine performs this recycling
 651      * process automatically as needed, in a separate thread, even if the
 652      * {@code gc} method is not invoked explicitly.
 653      * <p>
 654      * The method {@link System#gc()} is the conventional and convenient
 655      * means of invoking this method.
 656      */
 657     public native void gc();
 658 
 659     /**
 660      * Runs the finalization methods of any objects pending finalization.
 661      * Calling this method suggests that the Java virtual machine expend
 662      * effort toward running the {@code finalize} methods of objects
 663      * that have been found to be discarded but whose {@code finalize}
 664      * methods have not yet been run. When control returns from the
 665      * method call, the virtual machine has made a best effort to
 666      * complete all outstanding finalizations.
 667      * <p>
 668      * The virtual machine performs the finalization process
 669      * automatically as needed, in a separate thread, if the
 670      * {@code runFinalization} method is not invoked explicitly.
 671      * <p>
 672      * The method {@link System#runFinalization()} is the conventional
 673      * and convenient means of invoking this method.
 674      *
 675      * @see     java.lang.Object#finalize()
 676      */
 677     public void runFinalization() {
 678         SharedSecrets.getJavaLangRefAccess().runFinalization();
 679     }
 680 
 681     /**
 682      * Not implemented, does nothing.
 683      *
 684      * @deprecated
 685      * This method was intended to control instruction tracing.
 686      * It has been superseded by JVM-specific tracing mechanisms.
 687      * This method is subject to removal in a future version of Java SE.
 688      *
 689      * @param on ignored
 690      */
 691     @Deprecated(since="9", forRemoval=true)
 692     public void traceInstructions(boolean on) { }
 693 
 694     /**
 695      * Not implemented, does nothing.
 696      *
 697      * @deprecated
 698      * This method was intended to control method call tracing.
 699      * It has been superseded by JVM-specific tracing mechanisms.
 700      * This method is subject to removal in a future version of Java SE.
 701      *
 702      * @param on ignored
 703      */
 704     @Deprecated(since="9", forRemoval=true)
 705     public void traceMethodCalls(boolean on) { }
 706 
 707     /**
 708      * Loads the native library specified by the filename argument.  The filename
 709      * argument must be an absolute path name.
 710      * (for example
 711      * {@code Runtime.getRuntime().load("/home/avh/lib/libX11.so");}).
 712      *
 713      * If the filename argument, when stripped of any platform-specific library
 714      * prefix, path, and file extension, indicates a library whose name is,
 715      * for example, L, and a native library called L is statically linked
 716      * with the VM, then the JNI_OnLoad_L function exported by the library
 717      * is invoked rather than attempting to load a dynamic library.
 718      * A filename matching the argument does not have to exist in the file
 719      * system.
 720      * See the <a href="{@docRoot}/../specs/jni/index.html"> JNI Specification</a>
 721      * for more details.
 722      *
 723      * Otherwise, the filename argument is mapped to a native library image in
 724      * an implementation-dependent manner.
 725      * <p>


< prev index next >