Re: Memory leaks revisited

David Hakim <dhakim-Gkm/TONP9n1Wk0Htik3J/[email protected]> Fri, 2 May 2003 10:50:10 -0400
Newsgroups gmane.comp.lang.moto.devel
Message-ID <[email protected]>
The reason this fails in both modes is that the allocation of 7 
UnArrays and one string of 4 bytes in each loop iteration is 
unavoidable so the 32 megs of default shared heap is used up. Without a 
true garbage collector (or good reference counting scheme) that can 
determine which of the previously allocated objects are no longer 
referenced we must wait until the end of page execution to free them.

However this isn't usually a problem since a single page executing 
doesn't in general use that much memory. But once the shared heap 
maximum is reached, memory can no longer be allocated. This is unlike 
system malloc which can keep allocating forever. This is one of the 
real downsides of moto's shared memory manager. It cannot grow above 
the size originally specified (by default 32 megs) . The reason it 
can't is because it uses mmap to get a blank area in memory to manage. 
Once that area is used up I don't know of a good way to ask the 
operating system for another shared segment which can then be used by 
other processes as well as the requesting process. This problem could 
be managed by using system five shmXXX functions, however those have 
the alternate problem of not going away when all the processes that are 
using them are killed.

-Dave

On Friday, May 2, 2003, at 11:13  AM, Stefano Corsi wrote:

> I'm still experimenting with odd, iterative tests:
>
> void test3(int count) {
>     for (int a = 0; a < 100; a++) {
>         for (int i = 0; i < seed; i++) {
>             String arr[][][][][][][] = <String[][][][][][][]>{{{{{{{ 
> "dog"
> }}}}}}};
>             print arr[0][0][0][0][0][0][0] + "\n";
>         }
>     }
> }
>
> test3(1000);
>
> This one fails with both moto_0_19_1 and my moto_opo branch:
>
> ### Allocation failure!
> Uncaught AllocationFailureException
>    message:
>
> AllocationFailureException thrown in test3(excpfn.c:47)
>    called from function <main>(prova.moto:12)
>
> The strange thing is that it fails also in compiled mode:
>
> ### Allocation failure!
> ### Allocation failure!
> Segmentation fault
>
> It succeds, on the other side, with count = 100 and prints "dog" 10.000
> times...
>
> test3(100);
>
> Stefano
>
>
>