annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15746
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15625
diff changeset
1 ## Copyright (C) 2010 Philip Nienhuis
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2 ##
15746
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15625
diff changeset
3 ## This file is part of Octave.
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15625
diff changeset
4 ##
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15625
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15625
diff changeset
6 ## under the terms of the GNU General Public License as published by
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15625
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15625
diff changeset
8 ## your option) any later version.
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15625
diff changeset
9 ##
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15625
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15625
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15625
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15625
diff changeset
13 ## General Public License for more details.
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15625
diff changeset
14 ##
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 ## -*- texinfo -*-
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
20 ## @deftypefn {Function File} {} javamem ()
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
21 ## @deftypefnx {Function File} {@var{jmem} =} javamem ()
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
22 ## Show the current memory usage of the Java virtual machine (JVM)
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
23 ## and run the garbage collector.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 ##
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
25 ## When no return argument is given the info is printed to the screen.
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
26 ## Otherwise, the output cell array @var{jmem} contains Maximum, Total,
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 ## and Free memory (in bytes).
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 ##
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 ## All Java-based routines are run in the JVM's shared memory pool,
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 ## a dedicated and separate part of memory claimed by the JVM from
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 ## your computer's total memory (which comprises physical RAM and
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 ## virtual memory / swap space on hard disk).
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 ##
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
34 ## The maximum allowable memory usage can be set using the file java.opts
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 ## (in the same subdirectory where javaaddpath.m lives, see
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
36 ## "which javaaddpath". Usually that is:
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
37 ##
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
38 ## @file{OCTAVE_HOME/share/octave/OCTAVE_VERSION/m/java/}
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 ##
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
40 ## java.opts is a plain text file with one option per line. The
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 ## default initial memory size and default maximum memory size (which
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
42 ## are both system dependent) can be overridden like so:
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
43 ##
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
44 ## @nospell{-Xms64m}
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
45 ##
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
46 ## @nospell{-Xmx512m}
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
47 ##
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 ## (in megabytes in this example.)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 ## You can adapt these values to your own requirements if your system
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
50 ## has limited available physical memory or if you get Java memory
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 ## errors.
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 ##
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 ## "Total memory" is what the operating system has currently assigned
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 ## to the JVM and depends on actual and active memory usage.
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
55 ## "Free memory" is self-explanatory. During operation of Java-based
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
56 ## Octave functions the amount of Total and Free memory will vary,
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 ## due to Java's own cleaning up and your operating system's memory
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 ## management.
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 ## @end deftypefn
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 ## Author: Philip Nienhuis
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 ## Created: 2010-03-25
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 ## Updates:
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 ## 2010-03-26 Changed name to javamem & indentation to double spaces
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 ## 2010-08-25 Corrected text on java memory assignments
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 ## 2010-09-05 Further overhauled help text
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
68 function jmem = javamem ()
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
70 rt = java_invoke ("java.lang.Runtime", "getRuntime");
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 rt.gc;
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
72 jvmem = cell (3, 1);
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
73 jvmem{1} = rt.maxMemory ().doubleValue ();
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
74 jvmem{2} = rt.totalMemory ().doubleValue ();
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
75 jvmem{3} = rt.freeMemory ().doubleValue ();
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
77 if (nargout == 0)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 printf ("\nJava virtual machine (JVM) memory info:\n");
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
79 printf ("Maximum available memory: %5d MiB;\n",
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
80 jvmem{1} / 1024 / 1024);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 printf (" (...running garbage collector...)\n");
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 printf ("OK, current status:\n");
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
83 printf ("Total memory in virtual machine: %5d MiB;\n",
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
84 jvmem{2} / 1024 / 1024);
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
85 printf ("Free memory in virtual machine: %5d MiB;\n",
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
86 jvmem{3} / 1024 / 1024);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 printf ("%d CPUs available.\n", rt.availableProcessors ());
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 else
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
89 jmem = jvmem;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 endif
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 endfunction
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
93