Database Reference
In-Depth Information
simple. These figures are the result of calling some XQuery functions from eXist's
system module; to understand how to interpret these, see “XQuery” on page 391 .
XQuery
eXist provides three XQuery functions that may be used to interrogate the JVM in its
system extension module (see system ). The functions are:
system:get-memory-max
Reports the maximum memory available to the JVM running eXist (i.e., the value
of the -Xmx setting).
system:get-memory-free
Reports memory that is allocated, but free and available for reuse.
system:get-memory-total
Reports the currently allocated memory within the JVM. This is made up of both
memory that is in use and memory that is free for reuse. Subtracting
system:get-memory-free from this tells you exactly how much memory eXist is
using.
The following simple XQuery reports on the memory status:
xquery version "3.0" ;
declare function local:human-units ( $ bytes ) {
let $ unit := if ( $ bytes > math:pow ( 1024 , 3 )) then
( math:pow ( 1024 , 3 ), "GB" )
else if ( $ bytes > math:pow ( 1024 , 2 )) then
( math:pow ( 1024 , 2 ), "MB" )
else
( 1024 , "KB" )
return
format-number ( $ bytes div $ unit [ 1 ], ".00" ) || " " || $ unit [ 2 ]
};
<memory>
<max> { local:human-units ( system:get-memory-max ())} </max>
<allocated>
<in-use> {
local:human-units (
system:get-memory-total ()
- system:get-memory-free ()
)
} </in-use>
<free> { local:human-units ( system:get-memory-free ())} </free>
<total> { local:human-units ( system:get-memory-total ())} </total>
</allocated>
<available> {
local:human-units (
Search WWH ::




Custom Search