Mercurial > hg > octave-lyh
comparison scripts/java/javamem.m @ 15772:0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Update docstrings. Use Octave coding conventions. Use default arguments
where possible. Match variable names in docstring to variable names in
function.
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: Rik <rik@octave.org>
HG: branch 'default'
* errordlg.m, helpdlg.m, inputdlg.m, javaArray.m, javaaddpath.m,
javaclasspath.m, javafields.m, javamem.m, javamethods.m, javarmpath.m,
listdlg.m, msgbox.m, questdlg.m, warndlg.m: Overhaul functions.
Update docstrings. Use Octave coding conventions. Use default arguments
where possible. Match variable names in docstring to variable names in
function.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 12 Dec 2012 13:48:47 -0800 |
parents | 54e8c2527a9e |
children | 921912c92102 |
comparison
equal
deleted
inserted
replaced
15771:4698ea77aa75 | 15772:0f1a143e5002 |
---|---|
15 ## You should have received a copy of the GNU General Public License | 15 ## You should have received a copy of the GNU General Public License |
16 ## along with Octave; see the file COPYING. If not, see | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | 17 ## <http://www.gnu.org/licenses/>. |
18 | 18 |
19 ## -*- texinfo -*- | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} javamem () | 20 ## @deftypefn {Function File} {} javamem () |
21 ## @deftypefnx {Function File} [@var{jmem}] = javamem () | 21 ## @deftypefnx {Function File} {@var{jmem} =} javamem () |
22 ## Show current memory status of the Java virtual machine (JVM) | 22 ## Show the current memory usage of the Java virtual machine (JVM) |
23 ## and run garbage collector. | 23 ## and run the garbage collector. |
24 ## | 24 ## |
25 ## When no return argument is given the info is echoed to the screen. | 25 ## When no return argument is given the info is printed to the screen. |
26 ## Otherwise, output cell array @var{jmem} contains Maximum, Total, | 26 ## Otherwise, the output cell array @var{jmem} contains Maximum, Total, |
27 ## and Free memory (in bytes). | 27 ## and Free memory (in bytes). |
28 ## | 28 ## |
29 ## All Java-based routines are run in the JVM's shared memory pool, | 29 ## All Java-based routines are run in the JVM's shared memory pool, |
30 ## a dedicated and separate part of memory claimed by the JVM from | 30 ## a dedicated and separate part of memory claimed by the JVM from |
31 ## your computer's total memory (which comprises physical RAM and | 31 ## your computer's total memory (which comprises physical RAM and |
32 ## virtual memory / swap space on hard disk). | 32 ## virtual memory / swap space on hard disk). |
33 ## | 33 ## |
34 ## The maximum available memory can be set using the file java.opts | 34 ## The maximum allowable memory usage can be set using the file java.opts |
35 ## (in the same subdirectory where javaaddpath.m lives, see | 35 ## (in the same subdirectory where javaaddpath.m lives, see |
36 ## "which javaaddpath". Usually that is: @* | 36 ## "which javaaddpath". Usually that is: |
37 ## [/usr]/share/octave/packages/java-<version>. | |
38 ## | 37 ## |
39 ## java.opts is a plain text file, one option per line. The | 38 ## @file{OCTAVE_HOME/share/octave/OCTAVE_VERSION/m/java/} |
39 ## | |
40 ## java.opts is a plain text file with one option per line. The | |
40 ## default initial memory size and default maximum memory size (which | 41 ## default initial memory size and default maximum memory size (which |
41 ## are both system dependent) can be overridden like so: @* | 42 ## are both system dependent) can be overridden like so: |
42 ## -Xms64m @* | 43 ## |
43 ## -Xmx512m @* | 44 ## @nospell{-Xms64m} |
45 ## | |
46 ## @nospell{-Xmx512m} | |
47 ## | |
44 ## (in megabytes in this example.) | 48 ## (in megabytes in this example.) |
45 ## You can adapt these values to your own requirements if your system | 49 ## You can adapt these values to your own requirements if your system |
46 ## has limited available physical memory or when you get Java memory | 50 ## has limited available physical memory or if you get Java memory |
47 ## errors. | 51 ## errors. |
48 ## | 52 ## |
49 ## "Total memory" is what the operating system has currently assigned | 53 ## "Total memory" is what the operating system has currently assigned |
50 ## to the JVM and depends on actual and active memory usage. | 54 ## to the JVM and depends on actual and active memory usage. |
51 ## "Free memory" is self-explanatory. During operation of Java-based | 55 ## "Free memory" is self-explanatory. During operation of Java-based |
52 ## octave functions the amounts of Total and Free memory will vary, | 56 ## Octave functions the amount of Total and Free memory will vary, |
53 ## due to Java's own cleaning up and your operating system's memory | 57 ## due to Java's own cleaning up and your operating system's memory |
54 ## management. | 58 ## management. |
55 ## @end deftypefn | 59 ## @end deftypefn |
56 | 60 |
57 ## Author: Philip Nienhuis | 61 ## Author: Philip Nienhuis |
59 ## Updates: | 63 ## Updates: |
60 ## 2010-03-26 Changed name to javamem & indentation to double spaces | 64 ## 2010-03-26 Changed name to javamem & indentation to double spaces |
61 ## 2010-08-25 Corrected text on java memory assignments | 65 ## 2010-08-25 Corrected text on java memory assignments |
62 ## 2010-09-05 Further overhauled help text | 66 ## 2010-09-05 Further overhauled help text |
63 | 67 |
64 function j_mem = javamem () | 68 function jmem = javamem () |
65 | 69 |
66 rt = java_invoke ("java.lang.Runtime", "getRuntime"); | 70 rt = java_invoke ("java.lang.Runtime", "getRuntime"); |
67 rt.gc; | 71 rt.gc; |
68 jmem = cell (3, 1); | 72 jvmem = cell (3, 1); |
69 jmem{1} = rt.maxMemory ().doubleValue (); | 73 jvmem{1} = rt.maxMemory ().doubleValue (); |
70 jmem{2} = rt.totalMemory ().doubleValue (); | 74 jvmem{2} = rt.totalMemory ().doubleValue (); |
71 jmem{3} = rt.freeMemory ().doubleValue (); | 75 jvmem{3} = rt.freeMemory ().doubleValue (); |
72 | 76 |
73 if (nargout == 0) | 77 if (nargout == 0) |
74 printf ("\nJava virtual machine (JVM) memory info:\n"); | 78 printf ("\nJava virtual machine (JVM) memory info:\n"); |
75 printf ("Maximum available memory: %5d MiB;\n", | 79 printf ("Maximum available memory: %5d MiB;\n", |
76 jmem{1} / 1024 / 1024); | 80 jvmem{1} / 1024 / 1024); |
77 printf (" (...running garbage collector...)\n"); | 81 printf (" (...running garbage collector...)\n"); |
78 printf ("OK, current status:\n"); | 82 printf ("OK, current status:\n"); |
79 printf ("Total memory in virtual machine: %5d MiB;\n", | 83 printf ("Total memory in virtual machine: %5d MiB;\n", |
80 jmem{2} / 1024 / 1024); | 84 jvmem{2} / 1024 / 1024); |
81 printf ("Free memory in virtual machine: %5d MiB;\n", | 85 printf ("Free memory in virtual machine: %5d MiB;\n", |
82 jmem{3} / 1024 / 1024); | 86 jvmem{3} / 1024 / 1024); |
83 printf ("%d CPUs available.\n", rt.availableProcessors ()); | 87 printf ("%d CPUs available.\n", rt.availableProcessors ()); |
84 else | 88 else |
85 j_mem = jmem; | 89 jmem = jvmem; |
86 endif | 90 endif |
87 | 91 |
88 endfunction | 92 endfunction |
93 |