XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

how to release the resources held by album instances (zune)?

Last post 05-28-2008 7:58 PM by sectionboy. 2 replies.
  • 05-28-2008 7:08 PM

    how to release the resources held by album instances (zune)?

    Hi, all,

     I try to tile the display with album arts ( 36 albums) in zune, but after about 6 draw() iterations, the program gave me a outofmemory exception. I believe it's because of the album instances held a lot of resources(?).  When is the album instance deconstructed, after each foreach iteration or after the whole foreach statement? Do I need to explicitly deconstruct it?

             foreach (Album album in mediaLibrary.Albums)
                {
                    spriteBatch.Draw(album.GetAlbumArt(Services), new Rectangle( somewhere ), Color.White);

                }

     

    Quote from xna help:

    Album resources such as art and thumbnails are cached in each Album instance. Retrieving and maintaining references to multiple instances of the same album, and accessing art or thumbnails on each of those instances, creates multiple copies of the art or thumbnails. Because large numbers of album art textures can consume considerable memory, it is not advisable to hold a large number of Album objects on which GetAlbumArt has been called.

  • 05-28-2008 7:40 PM In reply to

    Re: how to release the resources held by album instances (zune)?

    You need to manually call Dispose on the textures returned from GetAlbumArt. Also some albums will not have textures associated with them and could throw an exception.
    Ziggy

    Microsoft XNA MVP

    Ziggyware XNA News and Tutorials
  • 05-28-2008 7:58 PM In reply to

    Re: how to release the resources held by album instances (zune)?

    It worked. Thank you.
Page 1 of 1 (3 items) Previous Next