Jump to content
  • Advertisement

Archived

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

manuQuetelard

memory allocation

This topic is 5989 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, Since long time ago, I heard everywhere that memory allocation is very slow. how much slow really it is ?(more than a division? sqrt?). Thanks

Share this post


Link to post
Share on other sites
Advertisement
allocation must be slower than a division since division is implemented in hardware and memory allocation not.
however, it is not THAT slow, but you should avoid using it extensivly in the main game loop.

Share this post


Link to post
Share on other sites
I''ve written a small test app to check how slow (or fast) mem allocation is. It allocates 10MB of memory and frees it again. Doing this in a 1000-times-loop takes about 1790 miliseconds on my K6-iii@450 with 192ram.
I think memory allocation is not so time consuming, as long as it doesn''t have to use virtual memory.
(I''ve also noticed that there is a _huge_ difference in speed between the ''release'' and ''debug'' build. But actually I was too impatient to wait for the debug version to success )


===========================
UNKNOWN caused an invalid page fault in module unknown at 0000:bff80eb6
: win98 with multiple sclerose

Share this post


Link to post
Share on other sites
quote:
Original post by siaspete
In debug mode, the processor is spending much of the time filling that 10mb block with 0xCDCDCDCD ;-)



:D, or even 0x42696C6C, lol

===========================
UNKNOWN caused an invalid page fault in module unknown at 0000:bff80eb6
: win98 with multiple sclerose

Share this post


Link to post
Share on other sites
quote:
Original post by SwSh
I''ve written a small test app to check how slow (or fast) mem allocation is. It allocates 10MB of memory and frees it again. Doing this in a 1000-times-loop takes about 1790 miliseconds on my K6-iii@450 with 192ram.

This doesn''t sound like it models anything from the real-world, so the resultant figures are likely to be meaningless.

Share this post


Link to post
Share on other sites
I would say that memory allocation depends on "memory allocation list". If u allocating & freeing lot of 1Mb blocks, then it will take ( probably ) more time for finding enough space for 10Mb block. This is because, system will scan ( probably ) all pointers to free memory blocks & if all memory is consists of 1Mb blocks OS should unit them in one. Realloc() is trying to defragment memory, so sometimes it is good idea to use it

I''m not 100% sure for windows, but in DOS it was working this way...

Lekha

Share this post


Link to post
Share on other sites
Ok, you''re right. But it was only to show the order of magnitude.
Oh well, I''ve made another test and it took the computer about 4700ms to calculate 1000000000 sqrt''s. (with doubles)
(I had to put one _asm{nop} inside the loop, but it doesn''t slow down so much)

===========================
UNKNOWN caused an invalid page fault in module unknown at 0000:bff80eb6
: win98 with multiple sclerose

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!