Hi Eric,

Thank you for the quick response!! Unfortunately gc.collect() does not help. Furthermore, when I run my script for only a few iterations, it is able to complete, but holds onto its 12 GB of memory, even when idle (technically it drops ~50 MB every few minutes). Relaunching chimeraX obviously fixes this. In the original chimera, it appears that there was a command to reclaim memory "chimera.update.checkForChanges()" but I can't find a chimeraX version. Resetting the Log barely drops the memory. Do you have any other ideas?


If it helps, I will describe my code below:
Register a function, which itself is made of 5 functions, that samples a cryo-EM map at given coordinates (about 520 coordinates) and prints to file. I try to call this function several dozen times via a .cxc file, with each call of the function consuming ~3 GB.

The general function flow is:
1. Define a list of coordinates along defined unit vectors (12 in total, combined with the inverse vectors).
2. Create chimeraX markers at these coordinates. (each vector is assigned a model number, each marker is a residue. Ex: along the x-axis, #10:1, #10:2, #10:3 ...)
3. From all markers, `measure mapvalues` and assign values to an attribute
4. Assign a string attribute to each marker, naming them.
5. Save mapvalue attribute to .defattr file. Likewise save the marker string names.
6. Delete all markers.
7. New: gc.collect()


Best regards,

:David


On Wed, Feb 21, 2024 at 7:32 PM Eric Pettersen <pett@cgl.ucsf.edu> wrote:
Hi David,
        Python only reclaims memory when it runs "garbage collection" which, depending on the structure of your script, may or may not run in the context of your loop,  Try putting this after you close/delete markers and see if it helps:

        import gc
        gc.collect()

--Eric

        Eric Pettersen
        UCSF Computer Graphics Lab


> On Feb 21, 2024, at 4:26 PM, David Flesher via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
>
> Hi ChimeraX team,
>
> I've been writing a script to run within ChimeraX and, as I continue to run the script, the system memory quickly fills up to my system maximum (32 GB). Is there a way to refresh/dump the memory within ChimeraX? My script creates markers but deletes them with every iteration, which I thought would keep memory in check. Please let me know if you have any advice, thank you!
>
> Best regards,
>
> :David
> _______________________________________________
> ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu
> To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu
> Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/