Jump to content

  • Log In with Google      Sign In   
  • Create Account


XNA Content pipeline caching?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 XXChester   Members   -  Reputation: 794

Like
0Likes
Like

Posted 03 July 2011 - 04:58 PM

I was working on a game I have in the midsts and I noticed that there is a slight memory leak when I am hitting the replay button. So on a mission to fix this I found the problem, I forgot to call dispose on a texture before recreating it. Than things got interesting, even though I was specifically stating Content.Load<Texture2D>(sameTexture_as_disposed"); when I tried to assign its Name property a value it claims it is already disposed. Well, no, the old copy of this texture was disposed, now I am trying to reload it and assign the new texture a name.

Has anyone else noticed this and/or found documentation on the Content pipeline caching? I am not sure how to fix this problem other than to re-write the way the whole replay functionality works. In other API's I was able to just dispose of textures (within objects...same case here) and than reload them from the file system and viloa, no resource leaks, no false disposes.

Any insight into the caching would be great.
Thanks.

P.S. I was also thinking it could be because the GC isn't collecting the resource and that is why it is getting mixed up but I cannot see this being the case.


Remember to mark someones post as helpful if you found it so.

http://www.BrandonMcCulligh.ca


Sponsor:

#2 Flimflam   Members   -  Reputation: 653

Like
2Likes
Like

Posted 03 July 2011 - 10:43 PM

The content manager loads files once and hands the reference to everything else that tries to load the same file.

Do not call Dispose on anything loaded through the content pipeline: it's not your responsibility. Instead, dispose the content manager in question and it will properly unload the resources.

When it comes to a point where you want to be able to unload individual resources, start using multiple content managers. Then when you want to unload resources, dispose of the specific content manager and it will properly dispose of its contents.

#3 XXChester   Members   -  Reputation: 794

Like
0Likes
Like

Posted 04 July 2011 - 05:46 AM

Thanks a lot Flimflam that is exactly what I thought was happening.

Remember to mark someones post as helpful if you found it so.

http://www.BrandonMcCulligh.ca


#4 braindigitalis   Members   -  Reputation: 150

Like
0Likes
Like

Posted 04 July 2011 - 07:07 AM

XNA also caches custom content types, just to make you aware. I wasn't aware of this when i first attempted it, and found that when i modified certain parts of my object, it would alter the cached version too and not even a reload would read the original data. To fix this, i had to make a deep copy of the object (a level definition) and work on the copy.

just to let you know... :-)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS