trifork / erjang

A JVM-based Erlang VM
http://www.erjang.org
Apache License 2.0
725 stars 62 forks source link

EOF on stdin is not handled correctly (busy loop, mem leak) #32

Closed eriksoe closed 13 years ago

eriksoe commented 13 years ago

In FDDriverInstance, in the run() function in the anonymous Thread class, EOF is handled by sending EOF signal to finish(), then allocating nother 1K buffer and repeating. This busy loop means that on EOF, we have both a 100% CPU condition and (unless the receiver keeps up) a rapidly-growing-memory footprint issue.

eriksoe commented 13 years ago

Should the Thread.run() method simply return after calling finish(-1,_)?

krestenkrab commented 13 years ago

Feel free to write a succested fix :-). Seems like you already have it sorted out.

eriksoe commented 13 years ago

Yes, except that the finish(-1,_) line wasn't called at all; EOF is not signalled with an exception. Fixed now.