The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Making the memory fit

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Making the memory fit Posted: Jan 8, 2005 3:06 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Making the memory fit
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

One of the improvements I made in BottomFeeder in the last release was in memory consumption - it's lower now. Why is that? The answer gets into the configuration of ObjectMemory. One of the best things you can do is to read the class side comments in class ObjectMemory. In general, VisualWorks divides memory into 7 "zones" that are managed by the VM. The key for this problem lies in the following definition:

NewSpace
NewSpace is used to house newly created objects. It is composed of three sub-spaces: an object-creation space (Eden) and two SurvivorSpaces. When an object is first created, it is placed in Eden. When Eden starts to fill up (i.e., when the number of used bytes in Eden exceeds the scavenge threshold), the scavenger is invoked and those objects housed in Eden and the occupied SurvivorSpace that are still reachable from the system roots are copied to the unoccupied Survivor Space. Thereafter, those objects that survive each scavenge will be shuffled by the scavenger from the occupied SurvivorSpace to the unoccupied one, until such time that the aggregate size of these survivors threatens to make the scavenge pause excessively long (i.e., when the number of used bytes in SurvivorSpace exceeds the tenure threshold), whereupon the scavenger will attempt to speed up subsequent scavenges by moving some of the older surviving objects from NewSpace to OldSpace. We say that such objects are being 'tenured' to OldSpace.

New objects get created in eden, and then bounced to a survivor space. If the survivor spaces get filled too quickly, then objects get tenured into Old Space. Now, Old Space is the only part of Smalltalk memory that grows at runtime - and in garbage collection terms, the scavenger doesn't look to clean it up unless it's in extremis. So... if you create a lot of objects quickly - and don't have enough new space for them - they get tenured. This tends to grow memory that you really don't need. That's exactly what BottomFeeder was doing.

During the update cycle, here's what happens if a site gets queried:

  1. Fetch the XML source for the page
  2. Parse the XML Source into an XML document
  3. Convert the XML document into a feed object with items
  4. Process the items against what we already have for that feed, adding any new ones to it

That's repeated for each feed that gets updated. That's a lot of new objects, particularly if you have threaded updates on. In 3.7 and prior releases, New Space was too small - so lots of the transient objects (the XML document, the raw page source, etc) were being tenured as new space filled. With 3.8, I made sure that New Space is bigger. This had a big impact - I subscribe to 295 feeds, and it means that Bf now consumes 25MB less than it used to - and all just by looking at how my application used memory.

There can be big wins here for any application - both in footprint and performance. Have a look at the documentation for class ObjectMemory, and do some experimenting with the method #sizesAtStartup:

Read: Making the memory fit

Topic: Where was that left turn? Previous Topic   Next Topic Topic: Incorrect Blog Address

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use