Is there a way for me to poll system memory utilization? I am working in an AWS container that will crash out if I allocate more than my allotted memory (no swap), so I’m hoping to add some throttles to my pipeline if I am getting too close to the limit.
There is Sys.total_memory()
:
Get the total memory in RAM (including that which is currently used) in bytes.
and Sys.free_memory()
:
Get the total free memory in RAM in bytes.
Ideally Julia would just not use too much memory, but you could use new in 1.10:
--heap-size-hint=<size> Forces garbage collection if memory usage is higher than that value.
The memory hint might be specified in megabytes(500M) or gigabytes(1G)
It seems like that option should be redundant, maybe it will be, or at least you can ask Julia to try harder. Julia’s GC is getting better in 1.10 already (and on master) and I believe it will be released soon.
You can also set hard memory limits with Linux tools, but then your Julia will well crash if going over… That might be ok if you restart (automatically), and software should try to live up to that ideal:
Thanks @Palli! I’m aware of the GC hint, but I’m concerned with having too much memory in use, not so much cleaning up unneeded memory. And while it would be okay to let Julia crash, I’d like to avoid failure states to begin with using defensive checks and throttles, not dying completely from an avoidable issue.
Those Sys calls look perfect @barucden!