How to get current CPU and RAM usage in C++?

Sadly these things rely heavily on the underlying OS, so there are no platform-independent calls. (Maybe there are some wrapper frameworks, but I don’t know of any.) On Linux you could have a look at the getrusage() function call, on Windows you can use GetProcessMemoryInfo() for RAM Usage. Have also a look at the other … Read more

Google Colaboratory: misleading information about its GPU (only 5% RAM available to some users)

So to prevent another dozen of answers suggesting invalid in the context of this thread suggestion to !kill -9 -1, let’s close this thread: The answer is simple: As of this writing Google simply gives only 5% of GPU to some of us, whereas 100% to the others. Period. dec-2019 update: The problem still exists … Read more

Limit RAM usage to python program

I’ve done some research and found a function to get the memory from Linux systems here: Determine free RAM in Python and I modified it a bit to set the memory hard limit to half of the free memory available. import resource import sys def memory_limit(): “””Limit max memory usage to half.””” soft, hard = … Read more

How to get total RAM size of a device?

As of API level 16 you can now use the totalMem property of the MemoryInfo class. Like this: ActivityManager actManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo(); actManager.getMemoryInfo(memInfo); long totalMemory = memInfo.totalMem; Api level 15 and lower still requires to use the unix command as shown in cweiske’s answer.

MySQL maximum memory usage

MySQL’s maximum memory usage very much depends on hardware, your settings and the database itself. Hardware The hardware is the obvious part. The more RAM the merrier, faster disks ftw. Don’t believe those monthly or weekly news letters though. MySQL doesn’t scale linear – not even on Oracle hardware. It’s a little trickier than that. … Read more