How to limit memory use?

78 views
Skip to first unread message

Richard Cooke

unread,
Nov 14, 2022, 11:30:22 PM11/14/22
to GAM for Google Workspace
When I ran this command on a user:

gam config auto_batch_min 1 redirect csv ./filelistperms.csv multiprocess user someb o...@acme.com print filelist fields id,title,permissions,owners.emailaddress query "(visibility='domainCanFind' or visibility='domainWithLink')"

I watched it run for hours and hours.  When the file count got over 1.5 MILLION! (going up 100 at a time), I realized my system memory was getting low.

And as I watched, the swap memory was starting to get used.

This was my second attempt at this script, my first try was running unattended, and I came back to find my laptop crashed.  I see now it likely ran itself into the ground - out of memory.

So what/how do I avoid this?  Can I limit the number of files it processes?  Or better manage memory.  I assume its the results file that is filling memory because the file is not there or in the gam cache folder while its running, or after I Ctrl-C it.

Thanks in advance.

Richard Cooke

unread,
Nov 29, 2022, 10:04:31 AM11/29/22
to GAM for Google Workspace
I never did figure out how to limit either: 
 - The amount of RAM GAM uses for a file buffer, or
 - The number of items it processes at once.

Either would have made it easily workable on any machine. 

I wound up switching to a Ubuntu 20 box with 32GB of RAM and very fast CPUs.  On this machine, the first part that generates the raw file data took around 5 hours, the file was 1.7GB.  This was the step that was crashing my 16GB laptop.

The second command reduced that to a 243MB file with 1.65M lines!  

The third command took 8 DAYS to process all the files!

Watching the resource monitor, the only real impact was to RAM.  The CPUs were hardly doing anything.  Network traffic was pretty light for most of the time as well (surprisingly).

I'm posting this for the next person to run into this issue, and needs some idea of what to do:  Get more RAM.

Ross Scroggs

unread,
Nov 29, 2022, 10:48:08 AM11/29/22
to google-ap...@googlegroups.com
Richard,

Do: gam config verify
What is the value of: num_threads

This is how many parallel processes gam uses.

You mention three commands, I only see one. What are the others?

Ross

--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/a32b4ccb-6924-41fa-8076-513049fa030cn%40googlegroups.com.


--

Richard Cooke

unread,
Nov 29, 2022, 11:32:46 AM11/29/22
to GAM for Google Workspace
Hi Ross, how the heck are you?

num-threads = 5

I am adapting/using the commands from the script "GetSharedWithDomainDriveACLs.py".  The 3 commands, done one user at at time, are:
  1. gam config auto_batch_min 1 redirect csv ./filelistperms.csv multiprocess user road_...@acme.com print filelist fields id,title,permissions,owners.emailaddress query "(visibility='domainCanFind' or visibility='domainWithLink')"
  2. python3 GetSharedWithDomainDriveACLs.py filelistperms.csv deleteperms_road_runner.csv
  3. gam csv ./deleteperms_road_runner.csv gam user "~Owner" delete drivefileacl "~driveFileId" "~permissionId"
I did it this way to get records for each user on what files were changed, just in case....  Also handy to get the totals per user for my report.

Ross Scroggs

unread,
Nov 29, 2022, 11:38:48 AM11/29/22
to google-ap...@googlegroups.com
Richard,

Step 1 can be simplified as you are referencing a single user.
  1. gam redirect csv ./filelistperms.csv user road_...@acme.com print filelist fields id,title,permissions,owners.emailaddress query "(visibility='domainCanFind' or visibility='domainWithLink')"
Ross



--

Richard Cooke

unread,
Nov 29, 2022, 11:48:46 AM11/29/22
to GAM for Google Workspace
Thanks, but can you enlighten me on how that affects resources?

Before, I would watch the resource meter for free RAM slowly go down until it ran out.  Then the OS would try and use swap. At some point it runs out of any free RAM and just locks up.  So I thought the need was to limit how much it processed at once.  either by # of results, or RAM use.

Was I close?

Ross Scroggs

unread,
Nov 29, 2022, 11:55:24 AM11/29/22
to google-ap...@googlegroups.com
Richard,

"config auto_batch_min 1 redirect csv ./filelistperms.csv multiprocess" causes GAM to setup a child process to collect/merge the output
from all of the subprocesses; in your case, as there is a single user, there is no need for this. It probably isn't a big savings but run
a timed test of the two forms to see how much difference it makes.

Ross



--
Reply all
Reply to author
Forward
0 new messages