Jump to content
  • Advertisement
Sign in to follow this  
Eric_B

.Net GC good or bad for memory fragmentation?

This topic is 5470 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Good in general, but that doesn't mean it's better than your own custom pool-memory allocator, WHEN that alternative is suitable (which would of course also be faster too if you write it nicely).

Share this post


Link to post
Share on other sites
Quote:
Original post by DrPizza
Good; it can compact.


Does it mean that there is another level of indirection to access the object ? I mean, if object A is relocated, all the code which deals with this particular instance will have to know where it is now.

Wow. I posted a question :)

Regards,

Share this post


Link to post
Share on other sites
Whether it just rewrites the pointers (which it could do, as it knows where they are, after all) or uses pointer-to-pointers/indexes into an array of pointers/etc. I don't know.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Emmanuel Deloget
Does it mean that there is another level of indirection to access the object ? I mean, if object A is relocated, all the code which deals with this particular instance will have to know where it is now.


That's the nice part of managed code. All that is handled for you.

Share this post


Link to post
Share on other sites
Quote:
Original post by DrPizza
Whether it just rewrites the pointers (which it could do, as it knows where they are, after all) or uses pointer-to-pointers/indexes into an array of pointers/etc. I don't know.


If you're writing 'unsafe' code and want to take the address of a managed object, you have to first mark the object with the 'fixed' keyword to stop the garbage collector from moving it (i.e. when carrying out compacting). Raw pointers don't have any knowledge of what the garbage collector is doing, so if the object was moved it would then point to the wrong place in memory.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!