Pandemonium

November 11, 2008

Garbage, Part Two: anticlimax

Filed under: Tools and Software Development — bittermanandy @ 12:12 am

Oooooookaaaaaaaaaay, it seems that Part One wasn’t very interesting as nobody commented on it and not many people even read it. I personally think that the way C# manages garbage is fascinating and immensely clever. Perhaps I’m the only one!

So I was going to go into a similar level of detail for much more garbage-related stuff, and spread it out across three or four posts; but that seems a bit pointless given the previous response, a lot of effort for not much gain. I could instead write about it at a very high level, but you can find better resources elsewhere. Sorry… bit of a let-down this post. I’ll try to make up for it with the next one.

I’m planning to get what Pandemonium (such as it is so far) running on XNA 3.0 over the next few days, hopefully I’ll be able to write a bit about that. I’m looking forward to getting some actual gameplay up and running, not just the basic systems, which I intend to show as I go. I have a few other topic ideas too. Of course, if there’s anything you’d like me to cover, say the word. Check out the kind of things I’ve written about so far to see the kind of level I’m writing at (and for).

Back to normal good service soon…

Advertisements

19 Comments »

  1. as one of the few who read it, it’s not that i don’t find it kinda interesting… but on a day-to-day basis, it’s more than enough for me to know that it _does_ work, and that i can most of the time depend on it to do it’s job. In 5 years of programming in .Net, I’ve only had to manually tweak something for GC’s sake once.

    keep up the good articles… I’m reading a lot about XNA and game development in general, in the hopes that one of these days I’ll have the time and resources to actually start writing a game. My biggest problem is the graphics design… I’m not enough of an artist to pull off a convincing game, don’t know any that’d work for free, and can’t afford to hire one. 🙂 For example, I’ve downloaded the RPG starter kit, and played around with it a little, but very quickly realized that the number of custom sprite tiles that would need to be drawn put it WAY outside my skills.

    Comment by brian — November 11, 2008 @ 1:56 am | Reply

  2. Damn! I’ve been waiting for this article 8( Avoiding garbage collection is a really essential aspect to maintaining nice framerates on the xbox 360. I found the 1st article really good.

    Comment by Adam — November 11, 2008 @ 5:12 am | Reply

  3. What about an article explaining the new GS3 features you find while porting?

    Comment by andrewvos — November 11, 2008 @ 7:12 am | Reply

  4. aww, don’t let the apparent vacuum of the internet dissuade you. You’ve got some great content here, and by its very existence, the collective knowledge of the world is improved. Perhaps some small percentage truly understood your last post. Some other percentage tucks it in the back of their heads and it’ll be helpful at some time in the future when they least expect it. And perhaps some other percentage didn’t even read it, but will come across it via some google search.

    So, I guess, for whatever it’s worth … thanks for the articles so far 🙂

    Comment by Joel Martinez — November 11, 2008 @ 7:16 am | Reply

  5. Hi,

    I read your article on garbage collection and found it very interesting.
    It is a lot of hard work to write (and paint 🙂 ) those lengthy posts,
    be sure that a lot of people really appreciate it.

    Cheers and greetings,
    Marco

    Comment by Marco — November 11, 2008 @ 8:56 am | Reply

  6. Maybe if you updated more than once a month people would be more apt to leave comments.

    Comment by MasterSlowPoke — November 11, 2008 @ 10:47 am | Reply

  7. Actually I find all of your posts useful reading and the garbage collection posts were very enlightening, with a different tact than Shawn H did in his posts.
    Opens eye’s with just how some of the things we sometimes take for granted work and how best to with with then (as opposed to against them most of the time 🙂 )

    Comment by Simon (Darkside) Jackson — November 11, 2008 @ 10:50 am | Reply

  8. Hi Andy,

    keep up the good work mate, I find your blog extremely useful. People often read posts but don’t leave comments. Don’t let this dissuade you!

    Kostas, a former Rare (RnD) colleague

    Comment by thinkinggamer — November 11, 2008 @ 12:09 pm | Reply

  9. I agree, don’t stop! Your posts are great and full of useful stuff, keep em coming. GC on the 360 (or avoiding it) is very important, it’s nice to know how to do it well..

    Comment by Charles Humphrey — November 11, 2008 @ 12:22 pm | Reply

  10. FWIW I’m not planning on stopping anything, except that particular miniseries about garbage. It’s like… I’ve been on too many projects where features that really ought to have been cut were left in. They took a lot of work to complete but didn’t add anything to sales or review scores. They should have been cut long before the end. (I worked on at least one game that ought to have been canned completely, in fact AFAIK it’s still in development now with no end in sight, and no likelihood of breaking even if and when it does ever see the light of day). For games made by hobbyists (such as most XNA games) more than anything, knowing which features to cut and when (we all have wishlists when we begin our game that don’t get fulfilled) is key to getting the game finished.

    I’m just choosing to cut the Garbage Collection miniseries from the planned features of my blog, that’s all.

    MasterSlowPoke: of course, I started this blog with the best of intentions of better-than-weekly updates. Of course, I’ve not succeeded in that goal, which I regret somewhat and apologise for, though some people still seem to find it useful. But… how can I put this…? Maybe if I didn’t have a full time job, several other hobbies, a failing relationship with the girl I love, and both parents in hospital recovering from a car crash, the blog might be higher up my list of priorities and get updated more often. Capice?

    Kostas: hi! Long time no see. Hope all is well with you!

    Comment by bittermanandy — November 11, 2008 @ 1:19 pm | Reply

  11. Hi Andy,
    I thought the first article was really great, very informative and I have been checking daily for the sequel. In fact I think all your articles have been excellent.

    I’ve not yet seen (outside the printed book links you gave above and I didnt know they existed) a good article about the practicalities of avoiding garbage, and was really looking forward to the detail.

    I think it is an interesting topic, and totally key to writing performant XNA. Could you be persuaded to reconsider?

    Cheers,
    Kevin.

    Comment by Kevin — November 11, 2008 @ 4:04 pm | Reply

  12. Andy,

    Please continue this mini series, I think it will help many (not to mention me) Sorry to hear about your woes, the blog is the least of your worries (I know the feeling) but post when you can.

    If you decide to still kill this set, then thats cool to, I just think the community will lose a nice reference if you do.

    Keep on keeping on 🙂

    Comment by Charles Humphrey — November 11, 2008 @ 4:12 pm | Reply

  13. Im with everyone who posted above. The blog is great, and the garbage collector is very interesting. I read the first post, and it was good, but being part 1 only an introduction, so looked forward to the next section with interest. Dont cancel it!

    Maybe you do only post once a month, but every post is certainly worthwhile. Id rather a blog that updates when its necessary rather then one spewing rubbish into my reader 🙂

    Comment by Venatu — November 11, 2008 @ 5:44 pm | Reply

  14. Andy, don’t take the lack of comments as an indication that readers are not interested. Someone who casualy reads your blog will be enthralled with articles on flashy effects, but when someone is having trouble and actively looking for answers, the value of your GC posts will be much more apparent.

    Comment by Josh Usovsky — November 11, 2008 @ 6:38 pm | Reply

  15. Hi Andy,

    I’ve really been enjoying the posts, and was also hoping for a continuation of this particular series. I think a reason why you may not be getting as many hobbyists reading your website at this moment is because school season is upon us, and we don’t have as much time as we’d like to focus on learning other things. And I’m sure quite a few XNA programmers are indeed students. I’m sure the traffic will go back up during the summer.
    Regardless, I appreciate the work you put into these articles, and looking forward to whatever topic you decide to tackle next.

    Comment by Michal Gorecki — November 11, 2008 @ 6:50 pm | Reply

  16. Hey Andy – I’m following along too, though I catch your posts via Google reader so I’m guessing they don’t show up as hits on your blog. Anyway, I find stuff like garbage collection interesting, but sometimes I’m so far out of my element that I don’t feel like commenting and exposing my idiocy 😉

    Comment by Jim d — November 11, 2008 @ 7:58 pm | Reply

  17. I must also add that I did enjoy the article a lot – good job Andy – been checking the page every day in hope for the second part!
    Unfortunately I have no opportunity to do any gamedev in XNA, but am (still) hoping for a day when you could see C# gamedev jobs posts (I mean, not just tools related)!

    And I have a couple of (loosely) related questions/thoughts/discussion topics related to memory allocation under XNA – these strike me as possible serious problems when working on any bigger project on the resource-limited console platform(s):

    – quickly allocating objects on heap is all fine and nice, but what about cache coherency? Is there a strategy (if it’s possible at all) to allocate specific objects that you know that will be processed together so that they’re close in memory? Array of value types would be cache coherent, but when you allocate array of objects they can be all over the memory (and that’s exactly what you would do in a game).

    – what would be a way to track (and limit) memory usage in C#? I’ve frequently seen/used the strategy of using multiple heaps (textures, game, physics, etc) which can nicely control/limit the memory usage distribution during development.

    Anyway, thanks for the article and please continue!

    Comment by Filip — November 11, 2008 @ 9:33 pm | Reply

  18. > “what about cache coherency? Is there a strategy (if it’s possible at all) to allocate specific objects that you know that will be processed together so that they’re close in memory?”

    Yes! Perhaps I didn’t make it clear enough in Part One, but you get this “for free” as long as you allocate your coherency-sensitive objects at the same time. Think about it: every time you do an allocation, it just increments the pointer at the top of the heap. So if you do another allocation straight away, it will automatically be allocated right next to the first object in memory! And, because of the way live objects are “shuffled” together during a garbage collection, they’ll stay coherent as well even if they are moved.

    For the specific example you give of the array of objects: The array object would be allocated first, containing all the references (starting as null), then you’d allocate the actual objects in the array (filling in the references) – which would immediately follow the array object.

    > “what would be a way to track (and limit) memory usage in C#? I’ve frequently seen/used the strategy of using multiple heaps (textures, game, physics, etc)”

    AFAIK this is a little more tricky in C#/XNA than using a custom memory manager in C++. (On the other hand, you don’t have to write one!) Tracking the total is straightforward enough, but separating it into categories isn’t as simple, though techniques like pooling could still prove very valuable. (If you remember the recommendation of allocating everything at level change, and trying to hold off the next garbage collection until the next level change, you’ll see that your memor requirements can be highly predictable – depending on the type of game of course). Perhaps the XNA forums have some more ideas too.

    I guess an argument could be made that this kind of thing is less necessary in C#, but it’s not one that I’d make unreservedly. I suppose as with all such things, it’s a trade-off. Personally speaking, I use C# wherever I am able to nowadays as I believe the benefits outweight the disadvantages, but that’s not to say there’s no advantages to C++; if you need really fine-grained, low-level, per-byte memory management, C++ may be more appropriate.

    Comment by bittermanandy — November 11, 2008 @ 10:47 pm | Reply

  19. Now I wish I had commented… it was very informative I just hadn’t finished looking at all the references yet 😉 Please continue with the series!

    Comment by Paul Evans — November 12, 2008 @ 3:34 pm | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: