Re: [Pharo-users] memory question

2015-10-23 Thread Werner Kassens

Thank you Norbert and Alexandre,
#sizeInMemory was obviously what i was looking for. and  the hint 
about the little complication in a collection that can grow, was helpful 
indeed!

werner



Re: [Pharo-users] memory question

2015-10-23 Thread Alexandre Bergel
Well, this is not enough. This #sizeInMemory only tells you the size of the 
object, which is simply the number of variables * 4 + size of the header. 
For collection, such as OrderedCollection and Dictionary, it is worth asking 
#size and #capacity:
- #size tells you the amount of objects kept in the collection
- #capacity tells you the maximum size the collection can hold without 
triggering a grow operation.

For example:
Dictionary new sizeInMemory => 16

d := Dictionary new.
d at: #foo put: 1.
d sizeInMemory 
=> 16

d := Dictionary new.
d at: #foo put: 1.
d capacity 
=> 5

d := Dictionary new.
1 to: 1000 do: [ :i | d at: i put: i ].
d capacity 
=> 2213

d := Dictionary new.
1 to: 1000 do: [ :i | d at: i put: i ].
d size 
=> 1000

Alexandre




> On Oct 23, 2015, at 9:06 AM, Norbert Hartl  wrote:
> 
> 
>> Am 23.10.2015 um 13:29 schrieb Werner Kassens :
>> 
>> sorry, wrong thread, that was unintentional. werner
>> 
>> On 10/23/2015 01:24 PM, Werner Kassens wrote:
>>> Hi,
>>> i'd like to test how much memory a dictionary uses. i guess i could
>>> simply delete that dictionary and see how much memory the garbage
>>> collector releases, but i wonder how i could measure that without
>>> destroying that dictionary?
>>> werner
> 
> Try
> 
> Dictionary new sizeInMemory 
> 
> Norbert
> 
> 
> 

-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.






Re: [Pharo-users] memory question

2015-10-23 Thread Norbert Hartl

> Am 23.10.2015 um 13:29 schrieb Werner Kassens :
> 
> sorry, wrong thread, that was unintentional. werner
> 
> On 10/23/2015 01:24 PM, Werner Kassens wrote:
>> Hi,
>> i'd like to test how much memory a dictionary uses. i guess i could
>> simply delete that dictionary and see how much memory the garbage
>> collector releases, but i wonder how i could measure that without
>> destroying that dictionary?
>> werner

Try

Dictionary new sizeInMemory 

Norbert





Re: [Pharo-users] memory question

2015-10-23 Thread Werner Kassens

sorry, wrong thread, that was unintentional. werner

On 10/23/2015 01:24 PM, Werner Kassens wrote:

Hi,
i'd like to test how much memory a dictionary uses. i guess i could
simply delete that dictionary and see how much memory the garbage
collector releases, but i wonder how i could measure that without
destroying that dictionary?
werner






[Pharo-users] memory question

2015-10-23 Thread Werner Kassens

Hi,
i'd like to test how much memory a dictionary uses. i guess i could 
simply delete that dictionary and see how much memory the garbage 
collector releases, but i wonder how i could measure that without 
destroying that dictionary?

werner