[GAP Forum] Stop GAP from storing group properties

Stefan Kohl sk239 at st-andrews.ac.uk
Sat May 8 13:33:48 BST 2021


As to using `Unbind' for removing attribute values, one needs to be
a bit careful, since this leads to inconsistent objects. -- E.g.:

gap> G := SymmetricGroup(3);
Sym( [ 1 .. 3 ] )
gap> KnownAttributesOfObject(G);
[ "Size", "NrMovedPoints", "MovedPoints", "GeneratorsOfMagmaWithInverses",
  "MultiplicativeNeutralElement" ]
gap> Size(G);
6
gap> G!.Size;
6
gap> Unbind(G!.Size);
gap> Size(G);
Error, Record Element: '<rec>.Size' must have an assigned value
not in any function at *stdin*:15
type 'quit;' to quit to outer loop
gap> HasSize(G);
true
gap> IsSimple(G);
Error, Record Element: '<rec>.Size' must have an assigned value in
  Size( G ) at /user/GAP/gap-4.11.1/lib/grppc.gi:2317 called from
<function "IsSimpleGroup for solvable groups">( <arguments> )
 called from read-eval loop at *stdin*:15
type 'quit;' to quit to outer loop
gap> IsNilpotent(G);
Error, Record Element: '<rec>.Size' must have an assigned value in
  Size( grp ) at /user/GAP/gap-4.11.1/lib/pcgsperm.gi:378 called from
TryPcgsPermGroup( G, true, false, false
 ) at /user/GAP/gap-4.11.1/lib/grpperm.gi:1335 called from
PcgsCentralSeries( G ) at /user/GAP/gap-4.11.1/lib/grpperm.gi:1326 called from
<function "IsNilpotentGroup for permgrp">( <arguments> )
 called from read-eval loop at *stdin*:16
type 'quit;' to quit to outer loop

Calling GASMAN("collect") performs a garbage collection.
While a garbage collection will free dead bags (i.e. the space consumed by
objects which are not bound to any variable), it won't unbind variables and
remove their values (exception: weak pointer objects -- see ?WeakPointerObj).
In particular, a garbage collection does not remove attribute values or
their subobjects (except those only kept alive by weak pointers).

Hope this helps,

    Stefan

________________________________
From: Dima Pasechnik <dima at pasechnik.info>
Sent: Saturday, May 8, 2021 12:33 PM
To: Stefan Kohl <sk239 at st-andrews.ac.uk>
Cc: Marc Keilberg <keilberg at usc.edu>; GAP Forum <Forum at gap-system.org>
Subject: Re: [GAP Forum] Stop GAP from storing group properties

On Sat, May 08, 2021 at 10:07:00AM +0000, Stefan Kohl wrote:
> Dear Marc,
>
> there are at least two ways to achieve this.
> -- One of them is to use the function `AttributeValueNotSet',
> and another is to only pass the generators of the group to your testing function,
> and to create the group object locally inside that function.

I just wanted to mention Unbind(), a GAP function which allows one to remove
components from records, etc. - check its docs.

And (no longer documented?) GASMAN("collect")
to explicitly trigger garbade collection, something that might help keeping
memory consumption at bay.

HTH
Dima


>
> Does this help you? --
> Let me know if you have any further questions!
>
> Best regards,
>
>     Stefan
>
>
> ________________________________
> From: Marc Keilberg <keilberg at usc.edu>
> Sent: Saturday, May 8, 2021 4:01 AM
> To: GAP Forum <Forum at gap-system.org>
> Subject: [GAP Forum] Stop GAP from storing group properties
>
> Dear  GAP Forum,
>
> I've been looking to sift through a particular family of a few ten-thousand
> groups, which are not in any of the current libraries, to see if they have
> certain properties.  While it's relatively easy to construct the entire
> family of groups via the anupq package, and the test I run on them is
> relatively quick (a second or two per group on my computer), I run into
> serious memory consumption issues when I go to start testing them all (with
> a function specifically written to perform the test in question).  While
> the list of groups I want only takes up a few gigabytes, and each iteration
> of the testing function should be consuming a small fraction of that before
> it completes, my total memory consumption constantly ticks up as I run
> through the list, ultimately consuming well more memory than the list of
> groups itself.
>
> The problem, best as I can tell, is that in my function I must compute
> RationalClasses(Center(G)) for the given group G, and this information is
> getting stored in the group, resulting in ever increasing amounts of memory
> consumption as GAP iterates over my list of groups.  But I don't want or
> need it stored.  I have tried using ShallowCopy, but that doesn't help, as
> the group objects are all non-copyable apparently, so ShallowCopy,
> Immutable, StructuralCopy etc. all just return the original object instead
> of a wholly new one.  So it's still storing the information on the original
> group object, instead of a distinct copy that gets deleted upon the
> function completing.
>
> So is there any way I can prevent a testing function from storing
> properties of a group on that group after it completes, or otherwise delete
> any newly stored information before the function exits, and thereby prevent
> this excess memory consumption?
>
> Thanks,
> Marc
> _______________________________________________
> Forum mailing list
> Forum at gap-system.org
> https://mail.gap-system.org/mailman/listinfo/forum
> _______________________________________________
> Forum mailing list
> Forum at gap-system.org
> https://mail.gap-system.org/mailman/listinfo/forum


More information about the Forum mailing list