Utilizing computer memory to maximum

Solution 1:

The RAM used for a running task is only to store data. This is variables and stuff like that inside of your Python code. The CPU usage relates to the "thinking" of the program you are running.

So in this case, your program is doing a lot of thinking, but not a lot of storing.

Solution 2:

Your python program is CPU bottlenecked, not memory bottlenecked.

Think of it this way: Pretend you are writing a book with a pen on paper. You are writing as fast as you can. You can only write on one piece of paper at a time. Laying out 10 sheets of paper in front of you is not going to make you write ten times faster.

This is exactly what you are seeing. Your CPU is doing the "writing" as fast as it can. Hence it is at 100% utilization. The memory is the sheet of paper, which is the medium it works in.

If you want your program to run faster, you need more hands and/or write faster! If you had two hands, you could have one hand write the first chapter and the other hand write the next. Three hands? It can write the third chapter. All at the same time.

Assuming the program can be broken down into multiple tasks (if it isnt already), you could accomplish this by writing a multithreaded Python application. However, how to do that is outside the scope of Superuser.com.

Since you CPU is pegged at 100% and multicore CPUs are the norm today, odds are your Python program is already multithreaded. This most likely means in order to run the program faster, you need more CPU cores and/or faster cores.