-3

I am bit new to this computing world. I have a Python program running on visual Studio Code that uses high CPU memory but not GPU as shown in the figure.

However, my memory usage is very low as you can see.

Is there way to crank up the memory without touching GPU?

screenshot of the activity monitor

3
  • 2
    You cannot force an application to use more memory then that’s required.
    – Ramhound
    Commented Dec 3, 2021 at 3:06
  • Run it in 256 threads with no GUI (hidden). Commented Dec 3, 2021 at 3:31
  • 4
    "Is there way to crank up the memory ... ?" -- What do you think that would accomplish? What are you trying to achieve? "... that uses high CPU memory" -- That CPU metric has nothing to do with memory.
    – sawdust
    Commented Dec 3, 2021 at 4:01

2 Answers 2

2

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.

1
  • This isn't an answer to the question posed, but just commentary.
    – sawdust
    Commented Dec 3, 2021 at 4:44
1

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.

1
  • Thank you all for succinct answers. Things are clear now. This is what happens when a person(me) without much CS knowledge implements something on computer. Commented Dec 3, 2021 at 6:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .