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

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.
  • 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 In reply to

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

    Answer
    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.

    Localization: how to | titles support | the peer-review paradox | reviewers | Spanish
    Aran -- Let your game think!
  • 05-02-2008 12:12 PM In reply to

    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 In reply to

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

    Answer


    Jim Perry - Microsoft XNA MVP
    Here's what I'm up to.
    If people spent a minute searching the forums before posting I'd be out of a job.
  • 05-02-2008 12:46 PM In reply to

    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 In reply to

    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 kW Animation source code
Page 1 of 1 (6 items) Previous Next