caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "EL CHAAR Rabih   SGAM/AI/SAM" <RABIH.ELCHAAR@sgam.com>
To: "micha" <micha-1@fantasymail.de>
Cc: "caml-list" <caml-list@yquem.inria.fr>
Subject: RE: [Caml-list] allocating memory for c-structures
Date: Tue, 26 Dec 2006 19:32:00 +0100	[thread overview]
Message-ID: <7625D6A1880B4C4DA11D2EBB8B43D2B9167B41@FRDEF-EXMB03.europe.am.socgen> (raw)

The issue about having c structures allocated in ocaml heap is about:
1) having a floating pointer that could be displaced by the gc during its cycles (if it is emedded into ocaml heap)
2) having it reside in the c heap, and not be impacted by caml gc cycles (this can be justified if the c structure is heavy in memory, like a c array, ...): this is done by creating caml values with a custom or abstract tag.
3) memory freeing could always be done to a custom_tag value through the finalization function passed during the creation.

Hope this helps,
Rabih


-----Message d'origine-----
De : caml-list-bounces@yquem.inria.fr [mailto:caml-list-bounces@yquem.inria.fr] De la part de micha
Envoyé : mardi 26 décembre 2006 19:16
À : OCaml Mailing List
Objet : [Caml-list] allocating memory for c-structures

Normaly I allocate memory for c-structures with malloc or with "new" for 
c++ objects. Some time ago a read about a library which places external 
structures in strings of the interfacing languages (it was a scheme lib 
I think). So instead of using malloc or new I would allocate an 
ocaml-string and put the c-structure there. So it will be free by the gc.
That seems o.k. for me, any comments? I'm missing something?

cheers
 Michael

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de ses destinataires. 
Toute utilisation ou diffusion non autorisee est interdite. 
Tout message electronique est susceptible d'alteration. 
Societe Generale Asset Management et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie. 
  
Decouvrez l'offre et les services de Societe Generale Asset Management sur le site www.sgam.fr 
  
                                ******** 
  
This message and any attachments (the "message") are confidential and intended solely for the addressees. 
Any unauthorised use or dissemination is prohibited. 
E-mails are susceptible to alteration. 
Neither Societe Generale Asset Management nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified. 
 
Find out more about Societe Generale Asset Management's proposal on www.sgam.com


             reply	other threads:[~2006-12-26 18:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-26 18:32 EL CHAAR Rabih   SGAM/AI/SAM [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-12-26 18:15 micha
2006-12-26 18:33 ` [Caml-list] " skaller
2006-12-26 18:35 ` Richard Jones
2006-12-26 18:55   ` micha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7625D6A1880B4C4DA11D2EBB8B43D2B9167B41@FRDEF-EXMB03.europe.am.socgen \
    --to=rabih.elchaar@sgam.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=micha-1@fantasymail.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).