caml-list - the Caml user's mailing list
 help / color / Atom feed
* [Caml-list] Keeping track of values on the external heap
@ 2019-10-28 16:31 Markus Mottl
  0 siblings, 0 replies; only message in thread
From: Markus Mottl @ 2019-10-28 16:31 UTC (permalink / raw)
  To: OCaml List

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

Hi,

the runtime has recently seen some improvements for keeping track of memory
resources on the external heap, e.g. `caml_alloc_custom_mem`.  Though we
can now tell the GC the exact size on the external heap that custom values
consume at allocation time, we also need to keep track of values whose
memory consumption may change over their lifetime.

I've seen the new functions `caml_alloc_dependent_memory` and
`caml_free_dependent_memory`.  They are not mentioned anywhere in the
manual, but judging from the comment in their implementation, they appear
to address the above mentioned problem.

Is it the correct intended use if I keep track of the size of a custom
value at allocation time and, if it changes later, to pass the size
difference to `caml_alloc_dependent_memory` if it is positive (i.e. the
value grew) and its absolute value to `caml_free_dependent_memory` if it is
negative (i.e. the value shrank)?

Best regards,
Markus

-- 
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com

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

<div dir="ltr">Hi,<div><br></div><div>the runtime has recently seen some improvements for keeping track of memory resources on the external heap, e.g. `caml_alloc_custom_mem`.  Though we can now tell the GC the exact size on the external heap that custom values consume at allocation time, we also need to keep track of values whose memory consumption may change over their lifetime.</div><div><br></div><div>I&#39;ve seen the new functions `caml_alloc_dependent_memory` and `caml_free_dependent_memory`.  They are not mentioned anywhere in the manual, but judging from the comment in their implementation, they appear to address the above mentioned problem.</div><div><br></div><div>Is it the correct intended use if I keep track of the size of a custom value at allocation time and, if it changes later, to pass the size difference to `caml_alloc_dependent_memory` if it is positive (i.e. the value grew) and its absolute value to `caml_free_dependent_memory` if it is negative (i.e. the value shrank)?</div><div><br></div><div>Best regards,</div><div>Markus</div><div><br></div><div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Markus Mottl        <a href="http://www.ocaml.info" target="_blank">http://www.ocaml.info</a>        <a href="mailto:markus.mottl@gmail.com" target="_blank">markus.mottl@gmail.com</a></div></div></div>

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-28 16:31 [Caml-list] Keeping track of values on the external heap Markus Mottl

caml-list - the Caml user's mailing list

Archives are clonable:
	git clone --mirror http://inbox.vuxu.org/caml-list
	git clone --mirror https://inbox.ocaml.org/caml-list

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.caml-list


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git