Hi, I avoid OutOfMemory
errors with the function described here. This works for me on a Linux machine. I frequently call it (in my case in JuMP callbacks), and abort my program if the memory consumption reaches my predefined limit. You can, however, clearly write the return values to a *.log file.
Note that the function returns the current memory usage of your program, not of specific variables. Maybe this helps anyway.