home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / eiffel / 1075 < prev    next >
Encoding:
Internet Message Format  |  1992-08-19  |  1.8 KB

  1. Path: sparky!uunet!mcsun!uknet!mucs!cs.man.ac.uk!seanb
  2. From: seanb@cs.man.ac.uk (Sean Bechhofer)
  3. Newsgroups: comp.lang.eiffel
  4. Subject: CECIL and garbage collection
  5. Message-ID: <seanb.714234719@cs.man.ac.uk>
  6. Date: 19 Aug 92 14:31:59 GMT
  7. Sender: news@cs.man.ac.uk
  8. Lines: 43
  9.  
  10. Here's an interesting problem I've come up against in Eiffel 2.3, when
  11. using garbage collection and external C functions which create objects. As
  12. it says in the Environment manual, p.108:
  13.  
  14.         "What keeps the garbage collector from collecting Eiffel
  15.         objects that are only referenced in C code? Nothing. If
  16.         garbage collection is enabled, you must keep a reference
  17.         on the Eiffel side to prevent an object from being collected."
  18.  
  19. [Minor gripe: It would be nice to have this mentioned in the chapter on the
  20. CECIL interface. It took a while to find out quite why the code was
  21. behaving in a strange manner.]
  22.  
  23. In my code, an external C function is passed an Eiffel reference. The C
  24. builds an Eiffel tree (using eif_create, eif_rout, etc), then passes
  25. control back to Eiffel. The problem is that while the tree is being built,
  26. some of the nodes lower down the tree get garbage collected by Eiffel, with
  27. the effect that the result returned isn't what you'd expect.
  28.  
  29. I'd imagine there's a similar problem if you've got an Eiffel C archive
  30. compiled with garbage collection on, and some C wrapped around it. Calling
  31. into the Eiffel could cause objects created in the C code to be trashed. 
  32.  
  33.  
  34. So,
  35.  
  36.         o Any suggestions for a solution, other than simply turning
  37.       garbage collection off (via feature collection_off of class
  38.       MEMORY) while you're in the C world?  
  39.  
  40.         o Is this "feature" likely to change in Eiffel 3?
  41.  
  42. Cheers,
  43.  
  44.                 Sean Bechhofer
  45.                 seanb@cs.man.ac.uk
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.