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
MapleGcMark - mark an object contained in a MaplePointer during a garbage collection
Calling Sequence
MapleGcProtect(kv, s)
MapleGcAllow(kv, s)
MapleGcIsProtected(kv, s)
MapleGcMark(kv, s)
Parameters
kv
-
kernel handle of type MKernelVector
s
type ALGEB object
Description
These functions can be used in external code with OpenMaple or define_external.
MapleGcProtect 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, or associated with a MaplePointer mark function. This includes any external global or static ALGEB variables that will be referred to in a later external call. Failure to protect such a persistent variable can lead to unexpected results if the Maple garbage collector disposes of it between function calls.
MapleGcAllow 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 just means that the object obeys the same rules applied to all other Maple objects -- that they can be collected whenever there is no longer anything actively referring to them. Be careful not to allow garbage collection on any object that was not protected by you, or was protected prior to when your code was to protect it.
MapleGcIsProtected returns TRUE if the given object is protected from garbage collection.
MapleGcMark is used in combination with the MaplePointer mark function callback supplied by MaplePointerSetMarkFunction. It must be called only by such a callback. It is recommended that you use a MaplePointer with a mark function instead of protecting and unprotecting objects.
Examples
#include "maplec.h"
ALGEB M_DECL MySaveLast( MKernelVector kv, ALGEB *args )
{
static ALGEB last = NULL;
static M_BOOL was_protected = FALSE;
ALGEB prev;
if( !last ) {
last = ToMapleNULL(kv);
was_protected = MapleGcIsProtected(kv,last);
MapleGcProtect(kv,last);
}
if( MapleNumArgs(kv,(ALGEB)args) > 0 ) {
if( !was_protected )
MapleGcAllow(kv,last);
prev = last;
last = args[1];
return( prev );
return( last );
Execute the external function from Maple.
See Also
CustomWrapper, define_external, gc, OpenMaple, OpenMaple/C/API, OpenMaple/C/Examples, OpenMaple/C/MaplePointer
Download Help Document