Maple Professionel
Maple Académique
Maple Edition Étudiant
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professionel
MapleSim Académique
Maple T.A. - Suite d'examens de classement
Maple T.A. MAA Placement Test Suite
Möbius - Didacticiels de mathématiques en ligne
Machine Design / Industrial Automation
Aéronautique
Ingénierie des véhicules
Robotics
Energie
System Simulation and Analysis
Model development for HIL
Modélisation du procédé pour la conception de systèmes de contrôle
Robotics/Motion Control/Mechatronics
Other Application Areas
Enseignement des mathématiques
Enseignement de l’ingénierie
Enseignement secondaire et supérieur (CPGE, BTS)
Tests et évaluations
Etudiants
Modélisation financière
Recherche opérationnelle
Calcul haute performance
Physique
Webinaires en direct
Webinaires enregistrés
Agenda des évènements
Forum MaplePrimes
Blog Maplesoft
Membres Maplesoft
Maple Ambassador Program
MapleCloud
Livres blancs techniques
Bulletin électronique
Livres Maple
Math Matters
Portail des applications
Galerie de modèles MapleSim
Cas d'Etudes Utilisateur
Exploring Engineering Fundamentals
Concepts d’enseignement avec Maple
Centre d’accueil utilisateur Maplesoft
Centre de ressources pour enseignants
Centre d’assistance aux étudiants
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