caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Finding "lost" references to OCaml heap values
@ 2015-10-06 13:43 Richard W.M. Jones
  2015-10-06 14:16 ` Richard W.M. Jones
  0 siblings, 1 reply; 8+ messages in thread
From: Richard W.M. Jones @ 2015-10-06 13:43 UTC (permalink / raw)
  To: caml-list


I guess I have two questions:

(1) Is calling Gc.compact () guaranteed to call the finalizer of any
object which is no longer reachable, under all circumstances?  Or
would there be some case where it wouldn't be called?

(2) I have a large mixed OCaml / C program[a] where somehow calling
Gc.compact isn't calling the destructor of a (very) large object.
Manual code inspection has not revealed anything so far --
superficially it appears we are not holding any references to the
object.  Is there any method / library / tool that can inspect the
OCaml heap and find references to an object?

Rich.

[a] https://github.com/libguestfs/libguestfs/tree/master/v2v

-- 
Richard Jones
Red Hat

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [Caml-list] Finding "lost" references to OCaml heap values
@ 2015-10-06 13:57 Maxime Ransan (BLOOMBERG/ 731 LEX)
  2015-10-06 15:53 ` Richard W.M. Jones
  0 siblings, 1 reply; 8+ messages in thread
From: Maxime Ransan (BLOOMBERG/ 731 LEX) @ 2015-10-06 13:57 UTC (permalink / raw)
  To: rich; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 1431 bytes --]

Just a hint about why the destructor is not called is that when using caml_alloc_custom at  https://github.com/libguestfs/libguestfs/blob/master/v2v/xml-c.c#L139, you are setting the used parameter to 0.  

As mentioned in http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual033.html#toc150 you can increase the ratio. A quick check would be to use a (used = 1, max = 1).

From: rich@annexia.org At: Oct  6 2015 09:43:53
To: caml-list@inria.fr
Subject: Re:[Caml-list] Finding "lost" references to OCaml heap values


I guess I have two questions:

(1) Is calling Gc.compact () guaranteed to call the finalizer of any
object which is no longer reachable, under all circumstances?  Or
would there be some case where it wouldn't be called?

(2) I have a large mixed OCaml / C program[a] where somehow calling
Gc.compact isn't calling the destructor of a (very) large object.
Manual code inspection has not revealed anything so far --
superficially it appears we are not holding any references to the
object.  Is there any method / library / tool that can inspect the
OCaml heap and find references to an object?

Rich.

[a] https://github.com/libguestfs/libguestfs/tree/master/v2v

-- 
Richard Jones
Red Hat

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs



[-- Attachment #2: Type: text/html, Size: 3370 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-10-06 15:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-06 13:43 [Caml-list] Finding "lost" references to OCaml heap values Richard W.M. Jones
2015-10-06 14:16 ` Richard W.M. Jones
2015-10-06 15:09   ` Gerd Stolpmann
2015-10-06 15:17     ` Gabriel Scherer
2015-10-06 15:54       ` Richard W.M. Jones
2015-10-06 13:57 Maxime Ransan (BLOOMBERG/ 731 LEX)
2015-10-06 15:53 ` Richard W.M. Jones
2015-10-06 15:57   ` Richard W.M. Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).