question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'while' loop consumes up to 2 GB of RAM

See original GitHub issue

After iterating 30-60 000 times when running the AskScript program (below) node process consumed up to 2GB of RAM.

let a = 1
while(a>0) {
  if ((a/1000):equals(floor(a/1000))) {
    log(a)
  }
  a=a+1
}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
czerwinskilukasz1commented, Oct 8, 2020

@cpelican , good catch. After I submitted this error, mhagmajer reduced the allowed operation limit to just 10 000 operations (which is roughly around 600 iterations of a while loop, if I recall correctly), so no longer is it reproducible but if you changed the limit in https://github.com/xFAANG/askql/blob/master/src/askvm/index.ts#L20 to let’s say 10 000 000, you should be able to reproduce.

1reaction
mhagmajercommented, Jun 27, 2020

Seems like while will only be able to return the final value anyway @czerwinskilukasz1, https://github.com/xFAANG/askql/issues/239

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python : Memory consumption accumulating in a while loop
Line 95 of the code consumes ~30M of RAM as per the memory_profiler output. It's as if each iteration consumes 30M ending u...
Read more >
PC uses 2GB of RAM while idle.
That's normal. Windows caches a lot of data and can sit there with even more ram usage. 6GB RAM installed is a reasonable...
Read more >
How is the memory used increasing by using an infinite loop?
A plain infinite loop consumes CPU cycles, not increasing amounts of memory. If you have a process with an infinite loop, and its...
Read more >
How to Write Memory Efficient Loops in Python
Very simple but not memory efficient. Putting 500 images with (1000 x 1000) np.float64 pixels takes about 4 GB of memory, which at...
Read more >
Double Your Google Colab RAM in 10 Seconds Using a ...
OK, four words. But the important thing is, you don't need to worry about the Python version (Colab has both Python 2 and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found