Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7753343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:02:25+00:00 2026-06-01T12:02:25+00:00

I’m trying to see some things about processes in Linux and I have some

  • 0

I’m trying to see some things about processes in Linux and I have some questions that I hope you could answer for me.

I did this little program to see how it acts:

#!/bin/bash
count=1
while [ true ]
do
  echo "Counter $count "
  count=$(( $count + 1 ))
done

Is just an infinite loop.

Now, when I execute the program and use the top command in the shell, that process is the one the consumes more CPU resources:

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND   
4037 lola    20   0  16880 1248 1028 R   80  0.0   0:33.42 memoryleak.sh  

I let the program run for a time, but never exceeds 85% of CPU consumption, why is that? I guess that it is a mechanism of hygiene of the OP, but, if truth, which are the parameters to decide. Even more, the counter is still working, and, for what I see, could still work ad infinitum. Why is the CPU-intensive program not crashing the CPU?

Now, If I interrupt the process -sending a STOP signal-, and do a ps aux I get:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
lola       3896 24.4  0.0  16880  1248 pts/3    T    09:15   0:37 /bin/bash ./cpukilla.sh

Why, after stopped the process, the CPU consumption is still 24%? Should not be zero?

Any assistance would be appreciated.

EDIT: well, sorry for the “confusion” of the memory leak term. Never the less, it would not be technically a memory leak, because the count is consuming much memory without releasing it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:02:26+00:00Added an answer on June 1, 2026 at 12:02 pm

    If it never exceeds 85% of the CPU, that’s because the OS has other things calling on its resources. Lots of processes run on a multi-tasking system and it’s the job of the OS to keep them all playing nicely.

    In fact, under Linux (for one), if your process consistently uses its entire timeslice (ie, not yielding early), its priority will be downgraded as “punishment”.

    A CPU-intensive program won’t crash the operating system simply because the OS knows how to protect itself from such shenanigans 🙂

    As to the 24% figure, I’m not sure on that. It may be that the figure is based on program lifetime rather than the last few seconds, in which case it would reduce gradually (a series of ps -aux statements ten seconds apart would corroborate or destroy that theory, the former if it keeps reducing, that latter if it jumps up again).

    The man page doesn’t give a lot of detail on what the %cpu actually represents but does say:

    CPU usage is currently expressed as the percentage of time spent running during the entire lifetime of a process. This is not ideal, and it does not conform to the standards that ps otherwise conforms to. CPU usage is unlikely to add up to exactly 100%.

    This could be read as being a figure calculated over a time period rather (eg, last five minutes) than instantaneous (last second).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.