[GAP Forum] Memory management with GAP
Keshav Rao Kini
krkini at ntu.edu.sg
Wed Mar 23 16:36:25 GMT 2011
Well, I'll answer what I can...
2011/3/23 Mathieu Dutour <Mathieu.Dutour at ens.fr>
> ---Is there a way to know how much memory a variable occupies?
> The commands GasmanStatistics() is helpful but gives you only
> global information when what you want to know is more specific.
> Would it be possible to know how much memory a given variable
> uses? And the list of variables.
You can use MemoryUsage to get the memory usage of an object (with
some caveats - see the manual entry for details). NamesGVars will give
you a list of all the global variable names currently known to the GAP
interpreter.
> ---It is said that the garbage collection of GAP is "very conservative"
> What does that really mean?
I assume this means that it tries to avoid garbage-collecting any
objects until it is absolutely sure that there are no references to
it, but I don't know the actual details.
> ---In garbage collection, the problem is with cyclical links,
> a->b and b->a. Well I do not even know how to create such links,
> let alone cyclical in GAP.
> What command could lead to such cyclical links?
Well, one easy way is
gap> a := [];; b := [a];; a[1] := b;;
gap> a; b;
[ [ ~ ] ]
[ [ ~ ] ]
gap> a[1] = b; b[1] = a;
true
true
I guess this simple example is probably detectable to the garbage
collector, but there of course may be more complicated ones. By the
way, in the above, the notation "[ [ ~ ] ]" contains the symbol "~",
which means that object itself, i.e. the object is a list containing a
list containing the object itself. That's because a = b[1] = a[1][1].
-Keshav
CONFIDENTIALITY: This email is intended solely for the person(s) named and may be confidential and/or privileged. If you are not the intended recipient, please delete it, notify us and do not copy, use, or disclose its content. Thank you.
Towards A Sustainable Earth: Print Only When Necessary
More information about the Forum
mailing list