home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!mucs!cs.man.ac.uk!seanb
- From: seanb@cs.man.ac.uk (Sean Bechhofer)
- Newsgroups: comp.lang.eiffel
- Subject: CECIL and garbage collection
- Message-ID: <seanb.714234719@cs.man.ac.uk>
- Date: 19 Aug 92 14:31:59 GMT
- Sender: news@cs.man.ac.uk
- Lines: 43
-
- Here's an interesting problem I've come up against in Eiffel 2.3, when
- using garbage collection and external C functions which create objects. As
- it says in the Environment manual, p.108:
-
- "What keeps the garbage collector from collecting Eiffel
- objects that are only referenced in C code? Nothing. If
- garbage collection is enabled, you must keep a reference
- on the Eiffel side to prevent an object from being collected."
-
- [Minor gripe: It would be nice to have this mentioned in the chapter on the
- CECIL interface. It took a while to find out quite why the code was
- behaving in a strange manner.]
-
- In my code, an external C function is passed an Eiffel reference. The C
- builds an Eiffel tree (using eif_create, eif_rout, etc), then passes
- control back to Eiffel. The problem is that while the tree is being built,
- some of the nodes lower down the tree get garbage collected by Eiffel, with
- the effect that the result returned isn't what you'd expect.
-
- I'd imagine there's a similar problem if you've got an Eiffel C archive
- compiled with garbage collection on, and some C wrapped around it. Calling
- into the Eiffel could cause objects created in the C code to be trashed.
-
-
- So,
-
- o Any suggestions for a solution, other than simply turning
- garbage collection off (via feature collection_off of class
- MEMORY) while you're in the C world?
-
- o Is this "feature" likely to change in Eiffel 3?
-
- Cheers,
-
- Sean Bechhofer
- seanb@cs.man.ac.uk
-
-
-
-
-
-
-
-