Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource management; garbage collection #34

Open
phlegmaticprogrammer opened this issue Aug 9, 2011 · 1 comment
Open

resource management; garbage collection #34

phlegmaticprogrammer opened this issue Aug 9, 2011 · 1 comment

Comments

@phlegmaticprogrammer
Copy link
Owner

When an HttpConnection is opened, it should be closed when the Babel-17 program stops at the latest. An HttpConnection should also be closed, when it is garbage collected. There should be better guarantees for when something is garbage collected.
For example:

val stream = lang.io.curl "http://www.spiegel.de"
for line in stream.lines do
  #print line
end
## from here on stream is not mentioned anymore

The stream should be garbage collected and closed after the for loop. Maybe some sort of reference counting can help here.

@phlegmaticprogrammer
Copy link
Owner Author

Building reference counting into the current Babel-17 implementation would be very error prone because there is no single place where memory is allocated / deallocated, but memory is implicitly allocated by creating values all over the place. Furthermore, the current implementation has memory leaks where an experienced functional programmer would not expect them, so resource management would inherit these leaks. For now, it must be enough that resources can be explicitly closed and should be. As a safety net, the resource is closed when its memory is reclaimed via garbage collection. But for future implementations, that are needed for performance reasons anyway, this point needs to be revisited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant