shapr / ghclive

Google Summer of Code 2012 project, GHCi for the web
BSD 3-Clause "New" or "Revised" License
52 stars 7 forks source link

ghclive eats huge amounts of memory at [0..], 100% CPU #24

Open mikeplus64 opened 12 years ago

mikeplus64 commented 12 years ago

If a user types in [0..], ghclive alarmingly quickly consumes all your memory and 100% CPU, bringing the system to a grinding halt. In GHCi at least, a simple expression like [0..] won't leak huge amounts of memory -- in fact, GHCi's memory usage stays seems to stay about the same.

ekmett commented 12 years ago

There are a couple of fixes that could be applied. One is we could add lazy nodes to the result stream and then round trip to demand them when they are 'poked' by the user. Separately, we could limit the default recursion depth of Display, and make it insert those or just temporarily put '...' when it goes too deep. The trick then is naming those temporaries.