Browse thread
[Caml-list] Memory leak
-
Martin Jambon
- Martin Jambon
-
Brian Rogoff
-
Scott Cyphers
-
Markus Mottl
- Brian Rogoff
-
Markus Mottl
-
Scott Cyphers
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Brian Rogoff <bpr@b...> |
| Subject: | Re: [Caml-list] Memory leak |
On Wed, 17 Apr 2002, Markus Mottl wrote: > On Tue, 16 Apr 2002, Scott Cyphers wrote: > > > Sure. There was a great demo of this on the translator's list for the > > > O'Reilly book; create a representation of stacks based on arrays with a > > > top of stack index. Popping items off of the stack by moving the TOS > > > pointer around won't free them. Could you be doing something like that? > > > > In that particular case, the stack implementation is a lot uglier when you > > need to provide the ability to neutralize array elements of arbitrary type > > as you pop the stack. Sometimes you get lulled into thinking the GC works > > completely invisibly. > > In case you ever need such functionality (stacks based on arrays), you > might want to try the library of resizable arrays called RES, which also > handles resizable strings: > > http://www.ai.univie.ac.at/~markus/home/ocaml_sources.html Hey, don't they say "Never use Obj.magic!"? ;-) I thought the issue that Scott caught on the translator's list was nice, and very easy to overlook. The safe way to do this without using magic is to either change the interface to provide a value of the element type or to use options underneath and add another level of packing and unpacking. I don't know if that issue is FAQ worthy, but it belongs in some kind of "gotcha" list for Caml programmers. Really anyone using a GCed language with arrays may see that one... -- Brian ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners