[Vm-dev] Why spaceOkay test needed?

Andreas Raab andreas.raab at gmx.de
Mon Aug 20 16:37:41 UTC 2007

Adrian Lienhard wrote:
> Out of curiosity, does anybody know why in...
> primitiveNew
>     "Allocate a new fixed-size instance. Fail if the allocation would 
> leave less than lowSpaceThreshold bytes free. May cause a GC"
>     | class spaceOkay |
>     class := self stackTop.
>     "The following may cause GC!"
>     spaceOkay := self sufficientSpaceToInstantiate: class indexableSize: 0.
>     self success: spaceOkay.
>     successFlag ifTrue: [ self push: (self instantiateClass: self 
> popStack indexableSize: 0) ]
> ... there is the call to #sufficientSpaceToInstantiate:indexableSize: 
> although #instantiateClass:indexableSize: also indirectly calls 
> #sufficientSpaceToAllocate:?

Where does it do that?

> Both, the primitive fallback code and the vm code signal the low space 
> sem in case of failure.

The fallback code in the image is broken IMO. It needs to signal 
OutOfMemory instead of the low space semaphore. We had our servers go 
belly-up because of malformed requests that requested a 1 gigabyte or 
more memory.

   - Andreas

More information about the Vm-dev mailing list