Path: news.cs.au.dk!not-for-mail From: Stephan Erbs Korsholm Newsgroups: comp.lang.beta Subject: Re: Severe bug in array implementation (nti) - extendBlock: VirtualAlloc failed - Out of memory Date: 21 Feb 2000 14:40:23 +0100 Organization: University of Aarhus, Department of Computer Science (DAIMI) Lines: 52 Message-ID: References: <20000220103858.20518.qmail@noatun.mjolner.dk> NNTP-Posting-Host: geri.mjolner.dk X-Trace: xinwen.cs.au.dk 951140426 13054867 255.255.255.255 (21 Feb 2000 13:40:26 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 21 Feb 2000 13:40:26 GMT X-Newsreader: Gnus v5.7/Emacs 20.4 Xref: news.cs.au.dk comp.lang.beta:12246 Hello, Mr. Kimmel wrote, "I found a severe bug in the array implementation. The following program gives an access violation ..... (for i:32768 repeat [ ... ] 1->a.extend; '@'->a[a.range]; for);" Background: The reason for the access violation is that the system runs out of memory. This happens because the above program allocates a large series of memory blocks without ever doing any GC. The line 'a.extend' will allocate a new repetition in AOA (all repetitions are allocated in AOA). The contents of the old repetition is copied into the new one and the old repetition becomes garbage. Unfortunately this garbage is never collected since GC is never triggered. The reason for this is the following: GC is triggered when IOA runs full. Then an IOAGC is done, sometimes followed by an AOAGC. AOAGC can only happen after an IOAGC. But because the body of the loop never allocates anything in IOA, IOAGC is never triggered, which in turn prevents AOA from ever being collected. Fix: First of all, I would suggest that you double the length of the array instead of the rather small extension used above. Secondly you can force a GC by calling 'doGC' manually. 'doGC' is defined in betaenv and when called will force a GC. But this takes time, so be sure to call it just when you need it and not in every turn of the loop. I know the point of automatic storage reclamation is to release the user from having to call GC or freeing storage manually, but .... Kind Regards, Stephan Korsholm, Mjolner Informatics. -- ====================================================================== Stephan Korsholm, MSc C.S., Software Engineer, Mjolner Informatics ApS email - sek@mjolner.dk phone - +45 86 20 20 11 ... wait for tone, then dial ... 2757 fax - +45 70 27 43 44 (mark with 'Mjolner Informatics') address - Forskerparken, Gustav Wieds Vej 10, DK-8000 Aarhus C ======================================================================