Maple für Professional
Maple für Akademiker
Maple für Studenten
Maple Personal Edition
Maple Player
Maple Player für iPad
MapleSim für Professional
MapleSim für Akademiker
Maple T.A. - Testen & beurteilen
Maple T.A. MAA Placement Test Suite
Möbius - Online-Courseware
Machine Design / Industrial Automation
Luft- und Raumfahrt
Fahrzeugtechnik
Robotics
Energiebranche
System Simulation and Analysis
Model development for HIL
Anlagenmodelle für den Regelungsentwurf
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematikausbildung
Technik
Allgemein- und berufsbildende Schulen
Testen und beurteilen
Studierende
Finanzmodelle
Betriebsforschung
Hochleistungsrechnen
Physik
Live-Webinare
Aufgezeichnete Webinare
Geplante Veranstaltungen
MaplePrimes
Maplesoft-Blog
Maplesoft-Mitgliedschaft
Maple Ambassador Program
MapleCloud
Technische Whitepapers
E-Mail Newsletters
Maple-Bücher
Math Matters
Anwendungs-Center
MapleSim Modell-Galerie
Anwenderberichte
Exploring Engineering Fundamentals
Lehrkonzepte mit Maple
Maplesoft Welcome-Center
Resource-Center für Lehrer
Help-Center für Studierende
Notes on Memory Management with Java OpenMaple
Description
In Java OpenMaple, a Maple expression is represented by an Algebraic object. As long as this object is alive a reference to the corresponding Maple expression is kept. This reference keeps the Maple expression from being collected by the Maple garbage collector. Once the Algebraic object is freed in Java, the Maple expression may also be freed by Maple.
In general, this system works well and allows the user to ignore the details of memory management. Unfortunately, there are some situations where this system leads to poor memory usage. In these situations the user must take more responsibility for some memory issues.
This system fails when Java is creating many Algebraic objects without invoking the Java garbage collector. An example of this is a tight loop that creates an Algebraic for each iteration of the loop:
for ( i = 0; i < 100000; i++ )
{
kernel.evaluate( "Array( 1..100000, fill="+i+");" );
}
In this situation Maple is using a large amount of memory, but Java is not. Since Java is not using much memory, it does not invoke its garbage collector frequently. This means that the Algebraic objects returned by evaluate are not freed often. Therefore, the Maple rtables referred to by the Algebraic objects are not collected. Since these objects use a large amount of memory, Maple is forced to allocate a large amount of memory from the system.
Calling dispose breaks the link between the Algebraic and the corresponding Maple expression. By doing so Maple is free to collect the expression. The above code should be rewritten as follows:
a = kernel.evaluate( "Array( 1..100000, fill="+i+");" );
a.dispose();
In this case Maple is free to collect the memory used by an rtable any time after dispose has been called. Once the dispose member function has been called on an Algebraic no other member functions may be called except isDisposed.
See Also
gc, OpenMaple, OpenMaple/Java/Algebraic OpenMaple/Java/Algebraic/dispose, OpenMaple/Java/Algebraic/isDisposed OpenMaple/Java/Examples, OpenMaple/Java/API
Download Help Document