Inspect create new object string

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Inspect create new object string

Michel Duf
Hi,

When a just open a Inspector windows of String objects the quantity of
instance increase by the same number of objects that I have in my
inspector. Is that normal?

Example:

0. ByteString allInstances size   --->  80,000

1. TEST := Tools bossLoad: 'bossInfra18585397.bos'.  --- loading 20,000 strings

2. ByteString allInstances size   --->  100,000

3. TEST inspect

4. ByteString allInstances size   ---> 120,000

If I redo step 3 again I got 140,000, I  have a  5i1 VW image.

Michel

Reply | Threaded
Open this post in threaded view
|

Re: Inspect create new object string

Ricardo Birmann
Michel,

As mentioned on the other ongoing thread about Strings objects, Strings are not uniquely stored in Smalltalk, thus, when you inspect an object (and, therefore, send it a #printString message) new instances of String are going to be created.

There are, obviously some peculiarities involved here (probably something related to how the inspector is implemented, because you are not copying every instance (just 20,000 of them) on each inspect).

If you wait a while, these objects are going to be garbage collected so, besides the extra memory needed to open the inspector on such a large collection no harm is done. 120,000 ByteStrings is a lot... I can't think of what you would gain from inspecting this collection, I mean, you can't possibly go through them all to validate some logic (ok, ok, this is no excuse).

Try forcing a garbage collection between two inspects....

One more thing: I would not recommend you to use the returned value of "ByteString allInstances" in your business logic... I hope the reason for that is clear enough

Hope it helps,

Ricardo

On 8/24/06, Michel Dufour <[hidden email]> wrote:
Hi,

When a just open a Inspector windows of String objects the quantity of
instance increase by the same number of objects that I have in my
inspector. Is that normal?

Example:

0. ByteString allInstances size   --->  80,000

1. TEST := Tools bossLoad: 'bossInfra18585397.bos'.  --- loading 20,000 strings

2. ByteString allInstances size   --->  100,000

3. TEST inspect

4. ByteString allInstances size   ---> 120,000

If I redo step 3 again I got 140,000, I  have a  5i1 VW image.

Michel


Reply | Threaded
Open this post in threaded view
|

Re: Inspect create new object string

Alan Knight-2
In reply to this post by Michel Duf
Yes, that's what happens. It's because the inspector is caching the printStrings of all the field in the object. See resetFields. I expect that if you inspected an array containing the array of all string instances that you wouldn't see this. Of course that would be harder to do anything useful with.

At 10:55 AM 8/24/2006, Michel Dufour wrote:

>Hi,
>
>When a just open a Inspector windows of String objects the quantity of
>instance increase by the same number of objects that I have in my
>inspector. Is that normal?
>
>Example:
>
>0. ByteString allInstances size   --->  80,000
>
>1. TEST := Tools bossLoad: 'bossInfra18585397.bos'.  --- loading 20,000 strings
>
>2. ByteString allInstances size   --->  100,000
>
>3. TEST inspect
>
>4. ByteString allInstances size   ---> 120,000
>
>If I redo step 3 again I got 140,000, I  have a  5i1 VW image.
>
>Michel

--
Alan Knight [|], Cincom Smalltalk Development
[hidden email]
[hidden email]
http://www.cincom.com/smalltalk

"The Static Typing Philosophy: Make it fast. Make it right. Make it run." - Niall Ross