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
MapleGcProtect - prevent garbage collection on an object in external code
MapleGcAllow - allow garbage collection on an object in external code
MapleGcIsProtected - test if an object is protected from garbage collection in external code
Calling Sequence
MapleGcProtect(kv, s)
MapleGcAllow(kv, s)
MapleGcIsProtected(kv, s)
Parameters
kv
-
kernel handle returned by StartMaple
s
Maple object
Description
These functions are part of the OpenMaple interface to Microsoft Visual Basic.
The MapleGcProtect function prevents the object, s, from being collected by the Maple garbage collector. The memory pointed to by s is not freed until Maple exits, is restarted, or a call to MapleGcAllow is issued. Any Maple objects that must persist between external function invocations must be protected. This includes any external global or static Maple objects that will be referred to at a later time. Failure to protect such a persistent variable can lead to unexpected results if the Maple garbage collector disposes of it between function calls.
The MapleGcAllow function allows the Maple garbage collector to reclaim storage used by the object, s. This does not necessarily mean that the storage will be reclaimed. It means that the object obeys the same rules applied to all other Maple objects, that is, objects can be collected when they are no longer actively referred to. Ensure that you only unprotect objects that were protected by your call to MapleGcProtect. Do no use MapleGcAllow on objects that you did not protect.
Another way to prevent an object from being garbage collected is to assign it as the value of any global name.
MapleGcIsProtected returns TRUE if the given object is protected from garbage collection.
Examples
Sub KeepResults(ByVal kv As Long)
Dim table, r, i As Long
table = MapleTableAlloc(kv)
'important to protect this table so it isn't collected
MapleGcProtect kv, table
For i = 1 To 10
r = EvalMapleStatement(kv, "rand();")
MapleTableAssign kv, table, ToMapleInteger(kv, i), r
Next i
MapleGcAllow kv, table
End Sub
See Also
gc, OpenMaple, OpenMaple/VB/API, OpenMaple/VB/Examples
Download Help Document