Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

lndigo

Allocated memory

This topic is 5595 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

Hello, I use microsoft visual c++ 6 enterprise edition and my question is when my project is under debug and not release, it appears that whenever I allocat memory using malloc or new it adds an extra 4 bytes to the block. Is their a way to remove this?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Come on I need help :/

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
It could be something representing the size of the block

Share this post


Link to post
Share on other sites
What are you allocating? If it''s a struct, MSVC pads any variables out to 4bytes.... I''m not exactly sure what you''re doing, please be a bit more specific.

Share this post


Link to post
Share on other sites
MSVC in debug builds will allocate extra memory in front of and behind your memory to catch if you write out of the bounds of your memory. It sets this extra memory to 0xCC (I think) and later checks it and if it isn''t 0xCC you get a popup telling you about it.

------------
- outRider -

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
char *szString = (char*)malloc(10);

When I do this it will create a block of memory of 14 bytes. This is very anoying when trying to do pointer arithmatic. Is there a way I take this out D:

The extra bytes have a value of -3.

Share this post


Link to post
Share on other sites
The compiler adds that extra memory in a Debug build for safety reasons. That''s just the way things are.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!