[Vm-dev] Re: Limit of the #become:

Eliot Miranda eliot.miranda at gmail.com
Wed Apr 4 17:14:54 UTC 2012


On Wed, Apr 4, 2012 at 8:55 AM, Mariano Martinez Peck <marianopeck at gmail.com
> wrote:

>
>
>
> On Wed, Apr 4, 2012 at 5:32 PM, Mariano Martinez Peck <
> marianopeck at gmail.com> wrote:
>
>> Hi guys. I noticed that there is a limit in the number of objects you can
>> become. In my case, I am becoming 2312157 objects. So..I don't expect that
>> the become works. I imagine that it was not designed for so many objects in
>> mind ;)
>> However, what I would really understand is where is the limitation and
>> the reason.
>
>


The limitation is in the number of forwarding blocks.  For a two-way become
you need N * 2 forwarding blocks.  for a become forward 1-way become you
need N forwarding blocks.  Each forwarding block takes two words (a saved
header word and the new location).  During forwarding each forwarded
object's header is changed to a pointer to its forwarding block.
 See prepareForwardingTableForBecoming:with:twoWay: & fwdTableInit:.  The
number of forwarding blocks available depend on the amount of unused heap
memory.   So there is no fixed limit and growing memory will lift the
limit, as may doing a GC (as you yourself found).



> And of course, if someone already knows which is the real number limit.
>> Otherwise, I will do a kind of binary search and discover it.
>>
>> If you want to reproduce it:
>>
>> | dict |
>> dict := Dictionary new.
>> 2312157 timesRepeat: [ dict at: Object new put: Object new ].
>> 3 timesRepeat: [Smalltalk garbageCollect].
>> dict keys elementsForwardIdentityTo: dict values.
>>
>> throws a #primitiveFailed.
>>
>
> Of course the following works correctly:
>
> | dict tmp |
> dict := Dictionary new.
> 2312157 timesRepeat: [dict at: Object new put: Object new].
> 3 timesRepeat: [Smalltalk garbageCollect].
> dict associations groupsOf: 50000 atATimeDo: [:each |
>     tmp := Dictionary withAll: each.
>     tmp keys elementsForwardIdentityTo: tmp values
>     ]
>
>
> So... indeed, there seems to be a limit with the amount of objects.
>
>
>
>>
>> Thanks,
>>
>> --
>> Mariano
>> http://marianopeck.wordpress.com
>>
>>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>
>


-- 
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20120404/cbdb1b67/attachment.htm


More information about the Vm-dev mailing list