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
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