Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

while(true) iteration runs out RAM memory

I am trying to figure out this issue:
I tried to run this two easy codes

int main(void) {
    while(1) {
       printf("Do nothing\n");
    }
   return 0;
}

When I execute it my memory RAM runs out.
Then I tried this variation:

int main(void) {
    while(1) {
       // do nothing
    }
   return 0;
}

And on that case my code runs without running out RAM.
My question is: why does it happen? Does printf occupied memory or maybe I am overloading stdout? Thanks!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If the terminal that is running out of memory, then yes, the terminal isn’t clearing the stdout properly.

If it’s the program itself running out of memory, then i don’t know actually.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading