Is there a way to reset memory?
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
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/
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/
Hi David, So, a few things. One is that it sounds like you are running your script with the ChimeraX graphical user interface up. Looking at what you say your script does, it doesn't seem like that's necessary. It will save some memory to run without the user interface by starting ChimeraX from the shell prompt with the --nogui and --exit flags, and your script file name as an argument. Another thing is are you actually deleting the markers (e.g. with the "delete" command) or are you closing the markers model? I would recommend the latter since it will be more efficient in cleaning things up, but deleting should work okay. Finally, and probably most importantly, you need to let the callbacks run that clean up references in the Python layer to dead objects. Probably the easiest way to do that is to replace the gc.collect() call with execution of the "wait 1" command. I hope this helps. --Eric
On Feb 21, 2024, at 5:09 PM, David Flesher via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
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 <mailto: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 <mailto: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 <mailto:chimerax-users@cgl.ucsf.edu> To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu <mailto:chimerax-users-leave@cgl.ucsf.edu> Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/ <https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/>
_______________________________________________ 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/
participants (2)
-
David Flesher
-
Eric Pettersen