home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 21212 < prev    next >
Encoding:
Text File  |  1993-01-11  |  1.8 KB  |  72 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!mcsun!sunic!kth.se!byse.nada.kth.se!d88-jwa
  3. From: d88-jwa@byse.nada.kth.se (Jon WΣtte)
  4. Subject: Re: TCL: Bizzare Behavior Time
  5. Message-ID: <1993Jan11.220137.26434@kth.se>
  6. Sender: usenet@kth.se (Usenet)
  7. Nntp-Posting-Host: byse.nada.kth.se
  8. Organization: Royal Institute of Technology, Stockholm, Sweden
  9. References: <1993Jan11.170231.17969@fsl.noaa.gov>
  10. Date: Mon, 11 Jan 1993 22:01:37 GMT
  11. Lines: 59
  12.  
  13. In <1993Jan11.170231.17969@fsl.noaa.gov> urban@yoda.fsl.noaa.gov (Art Urban) writes:
  14.  
  15. >Swatch reports that my application's heap has gone BAD BAD BAD BAD
  16. >(Swatch's words, not mine). I followed the source code until this condition
  17. >occured, and it happens right after a call to new ( anObject ). My TRY,
  18. >CATCH, ENDTRY doesn't blow up, so the call must've worked, yet my heap is
  19.  
  20. Well, you might get memory movement, and then assign a
  21. member variable of an object that moves? Something like:
  22.  
  23. class CFoo {
  24.  
  25.     CBar * theBar ;
  26.  
  27.     DoFoo ( ) ;
  28. } ;
  29.  
  30.  
  31. class CBar {
  32.  
  33.     IBar ( ) ;
  34.  
  35. } ;
  36.  
  37. CFoo :: DoFoo ( )
  38. {
  39.     theBar = new CBar ;
  40. }
  41.  
  42.  
  43. The call to new is risky unless you have locked the
  44. object doing the call; try an intermediate temp variable:
  45.  
  46. CFoo :: DoFoo ( )
  47. {
  48.     CBar * aBar = new CBar ;
  49.  
  50.     theBar = aBar ;
  51. }
  52.  
  53.  
  54. Also, you might have already trashed the stack before that,
  55. and thus trashed the implicit "this" parameter. Or you
  56. might be executing in /referencing a disposed object.
  57.  
  58. You _can_ trace "new" by adding the source for oops-library
  59. instead of the library (you have to fight to make it
  60. compile though)
  61.  
  62. Try MacsBug Heap Scramble, and Step Spy on the stack
  63. right after the call to the function that calls new.
  64.  
  65. Cheers,
  66.  
  67.                         / h+
  68. -- 
  69.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  70.    This signature is kept shorter than 4 lines in the interests of UseNet
  71.    S/N ratio.
  72.