home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!spool.mu.edu!yale.edu!yale!gumby!kzoo!k044477
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Subject: My GrowZoneFunc got a ridiculous request
- Message-ID: <1993Jan26.074553.8548@hobbes.kzoo.edu>
- Organization: Kalamazoo College
- Date: Tue, 26 Jan 1993 07:45:53 GMT
- Lines: 41
-
- My app went into an infinite loop this afternoon. When I broke into
- Macsbug this evening, I found that it was trying, over and over, to
- get enough memory to do a LoadResource().
-
- Upon perusal, it turned out that my GrowZoneFunc was being asked to
- allocate a bizarre amount of memory. Namely, 0xDA7DE240 bytes.
- That's well over three billion, or about -600,000,000 in signed decimal.
- An unusual request.
-
-
- It was in the infinite loop because the TCL's grow zone function,
- CApplication::GrowMemory(), checks to see whether bytesNeeded minus
- freeSpace is less than zero. That value, of course, was way less than
- zero, like about 600 megs less than zero, so it happily returned 1,
- telling the Memory Manager "there, I did it--try it now." The Memory
- Manager chokes on the request, re-calls the grow zone function, and
- things go on like this for, well, hours.
-
- When I forced CApplication::GrowMemory() to return 0, telling the Memory
- Manager "sorry, I give up--deny the request", everything worked OK until
- that resource was requested again. Then the GrowZoneFunc was again
- called and again asked to free up -600 megs.
-
-
- I'm guessing that the resource map is trashed, and that the long that
- should read the resource's actual size (about 24K) now reads
- "DA7DE240". That would explain it, I suppose. But my heap is fine, and
- Macsbug correctly tells me the type, ID, and name of every resource in
- it. So it's not _too_ corrupted. Let's see...well, after refusing that
- second request, the game has been working just fine for fifteen
- minutes. And ResEdit verifies the resource file as OK (it's big, 6.4
- megs).
-
- I figure if I patch GrowMemory() to return 0 if the request if absurd,
- that'll take care of the infinite looping. Should I just call this a
- fluke? Or what?
- --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- "I don't think people need optimization any more. ... If you look at the
- history of programming-language design, almost every major screw-up is a
- consequence of people pandering to some optimization...." - S. Wolfram
-