Do Multiple identical calls to ContentManager.Load load multiple copies of the same data?

Last post 05-02-2008, 4:20 PM by jwatte. 5 replies.
Sort Posts: Previous Next
  •  05-02-2008, 11:56 AM

    Do Multiple identical calls to ContentManager.Load load multiple copies of the same data?


    If I call the ContentManager Load method with the same info multiple times does it return muliple copies of the data, or multiple references to the same data?

    For example:

    Model model1 = contentManager.Load<Model>( ".\\content\\models\\box" );
    Model model2 = contentManager.Load<Model>( ".\\content\\models\\box" );


    Would the above store 2 independent copies of the box model in memory, or one copy in memory with 2 references to it?

    Or, to put it another way... if after executing the above code I modified model1's vertex buffer, would it affect model2's vertex buffer too?

    Thanks for your help
    Ben

  •  05-02-2008, 12:00 PM

    Re: Do Multiple identical calls to ContentManager.Load load multiple copies of the same data?

    Ben:

    If I call the ContentManager Load method with the same info multiple times does it return muliple copies of the data, or multiple references to the same data?


    The later. ContentManager uses an internal cache to return the same object when you use the same name.
  •  05-02-2008, 12:12 PM

    Re: Do Multiple identical calls to ContentManager.Load load multiple copies of the same data?

    Excellent thanks.

    For now thats exactly what I want, although I can forsee that in the future I might want a true duplicate (As per my example above if I want to modify one copy of the model but not another). Is there a way to force a real copy?

    Thanks
    Ben

  •  05-02-2008, 12:15 PM

    Re: Do Multiple identical calls to ContentManager.Load load multiple copies of the same data?

    See this thread.
    Jim Perry
    Here's what I'm up to.
  •  05-02-2008, 12:46 PM

    Re: Do Multiple identical calls to ContentManager.Load load multiple copies of the same data?

    Thanks, that thread answer that question too.

    Regards
    Ben

  •  05-02-2008, 4:20 PM

    Re: Do Multiple identical calls to ContentManager.Load load multiple copies of the same data?

    You can call Clone() if you want a separate copy.

    Note that there is no way to unload only a single asset -- and, worse, if you Dispose() an asset, it will not be purged from the cache. You have to clear the entire cache of the content manager to get rid of the asset.

    --
    Jon Watte, Direct3D MVP
    kW X-port 3ds Max .X exporter
    14 days after getting my RROD box back, it's going back for service again. Grr.
View as RSS news feed in XML
©2007 Microsoft Corporation. All rights reserved. Privacy Statement Terms of Use Code of Conduct Feedback