Re: Bug#509803: Fails to properly free memory on exit
Hello,
On 26-12-2008, Goswin Brederlow <goswin-v-b@web.de> wrote:
>
> Without ocaml calling the finalizer at exit one has to manually track
> allocated custom blocks causing 16 bytes (prev/next pointer) overhead
> per block and implement ones own cleanup code by using atexit() in an
> initializer, which is rather ugly.
Finalizer is something purely memory related for OCaml. The problem you
are describing is just a "hack" to avoid implementing a "close_out"-like
function. I really think you'd better implement a "close_out" function
for your aio binding.
Benefit of a AIO.close_out:
- free associated resource at a precise time (memory buffer, file
descriptor)
- get error status at the right time
- ensure operation is finished
- no need to _finalize
_finalize handle AIO.close_out:
- error is ignored (you cannot throw exception in finalizer)
- don't know when the file descriptor is freed, leading to possible
resource quota error (limit on memory, limit of open file descriptor)
- don't know precisely when last operation is finished (problem when you
write a temporary file and then reopen it to read data back)
- need to change OCaml to make _finalizer mandatory at the end of the
process.
Honestly, I really find that there is more problem doing the way you
propose than just making AIO.close_out mandatory just like
Pervasives.close_out.
>
> Please forward this upstream so ocaml can be made to call the
> finalizers at exit.
>
If you know this is an upstream bug, you should directly submit it
upstream. This is more simple for everyone.
Regards,
Sylvain Le Gall
Reply to: