@@ -158,6 +158,15 @@ FUNCTIONS
158158 Add a converter to the list used by to_python.
159159 :param converter: A Converter from java to python
160160
161+ available_processors() -> int
162+ Get the number of processors available to the JVM .
163+
164+ This function is a shortcut for Java' s
165+ Runtime.getRuntime().availableProcessors().
166+
167+ :return : The number of available processors.
168+ :raise RuntimeError : if the JVM has not yet been started.
169+
161170 enable_python_scripting(context)
162171 Adds a Python script runner object to the ObjectService of the given
163172 SciJava context. Intended for use in conjunction with
@@ -166,6 +175,13 @@ FUNCTIONS
166175 :param context: The org.scijava.Context containing the ObjectService
167176 where the PythonScriptRunner should be injected.
168177
178+ gc() -> None
179+ Do a round of Java garbage collection.
180+
181+ This function is a shortcut for Java' s System.gc().
182+
183+ :raise RuntimeError : if the JVM has not yet been started.
184+
169185 get_version(java_class_or_python_package) -> str
170186 Return the version of a Java class or Python package.
171187
@@ -254,12 +270,21 @@ FUNCTIONS
254270 jclass(data)
255271 Obtain a Java class object .
256272
257- :param data: The object from which to glean the class .
258273 Supported types include:
259- A. Name of a class to look up, analogous to
260- Class.forName(" java.lang.String" );
261- B. A jpype.JClass object analogous to String.class ;
262- C. A jpype.JObject instance analogous to o.getClass().
274+
275+ A. Name of a class to look up -- e.g. " java.lang.String" --
276+ which returns the equivalent of Class.forName(" java.lang.String" ).
277+
278+ B. A static- style class reference -- e.g. String --
279+ which returns the equivalent of String.class .
280+
281+ C. A Java object -- e.g. foo --
282+ which returns the equivalent of foo.getClass().
283+
284+ Note that if you pass a java.lang.Class object , you will get back Class.class ,
285+ i.e. the Java class for the Class class . :- )
286+
287+ :param data: The object from which to glean the class .
263288 :returns: A java.lang.Class object , suitable for use with reflection.
264289 :raises TypeError : if the argument is not one of the aforementioned types.
265290
@@ -297,28 +322,63 @@ FUNCTIONS
297322 Return true iff a Java virtual machine (JVM ) has been started.
298323
299324 jvm_version() -> str
300- Gets the version of the JVM as a tuple ,
301- with each dot- separated digit as one element.
302- Characters in the version string beyond only
303- numbers and dots are ignored, in line
304- with the java.version system property .
325+ Gets the version of the JVM as a tuple , with each dot- separated digit
326+ as one element. Characters in the version string beyond only numbers
327+ and dots are ignored, in line with the java.version system property .
305328
306329 Examples:
307330 * OpenJDK 17.0 .1 -> [17 , 0 , 1 ]
308331 * OpenJDK 11.0 .9.1- internal -> [11 , 0 , 9 , 1 ]
309332 * OpenJDK 1.8 .0_312 -> [1 , 8 , 0 ]
310333
311- If the JVM is already started,
312- this function should return the equivalent of:
334+ If the JVM is already started, this function returns the equivalent of:
313335 jimport(' java.lang.System' )
314336 .getProperty(' java.version' )
315337 .split(' .' )
316338
317- In case the JVM is not started yet,a best effort is made to deduce
339+ In case the JVM is not started yet, a best effort is made to deduce
318340 the version from the environment without actually starting up the
319341 JVM in - process. If the version cannot be deduced, a RuntimeError
320342 with the cause is raised.
321343
344+ memory_max() -> int
345+ Get the maximum amount of memory that the JVM will attempt to use.
346+
347+ This number will always be greater than or equal to memory_total().
348+
349+ In case the JVM was configured with - Xmx flag upon startup (e.g. using
350+ the scyjava.config.set_heap_max function), the value will typically
351+ correspond approximately, but not exactly, to the configured value.
352+
353+ This function is a shortcut for Java' s Runtime.getRuntime().maxMemory().
354+
355+ :return : The maximum memory in bytes .
356+ :raise RuntimeError : if the JVM has not yet been started.
357+
358+ memory_total() -> int
359+ Get the total amount of memory currently reserved by the JVM .
360+
361+ This number will always be less than or equal to memory_max().
362+
363+ In case the JVM was configured with - Xms flag upon startup (e.g. using
364+ the scyjava.config.set_heap_min function), the initial value will typically
365+ correspond approximately, but not exactly, to the configured value,
366+ although it is likely to grow over time as more Java objects are allocated.
367+
368+ This function is a shortcut for Java' s Runtime.getRuntime().totalMemory().
369+
370+ :return : The total memory in bytes .
371+ :raise RuntimeError : if the JVM has not yet been started.
372+
373+ memory_used() -> int
374+ Get the amount of memory currently in use by the JVM .
375+
376+ This function is a shortcut for
377+ Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory().
378+
379+ :return : The used memory in bytes .
380+ :raise RuntimeError : if the JVM has not yet been started.
381+
322382 shutdown_jvm() -> None
323383 Shutdown the JVM .
324384
@@ -338,6 +398,8 @@ FUNCTIONS
338398 Note that if the JVM is not already running, then this function does
339399 nothing! In particular, shutdown hooks are skipped in this situation.
340400
401+ :raises RuntimeError : if this method is called while in Jep mode.
402+
341403 start_jvm(options = None ) -> None
342404 Explicitly connect to the Java virtual machine (JVM ). Only one JVM can
343405 be active; does nothing if the JVM has already been started. Calling
0 commit comments