Ok so I was curious to see if an int actually weights 4 bytes on my ram.
so i made 1,000,000 ints with this code.
for(int i = 0;i < 1000000;++i)
int *as= new int;
Before I execute this line of code I put a breakpoint right before to see how much headover i'm starting with.
there is almost no headover, my program starts with 750 kb.
But after I finish the loop the program uses 32,000 kb when its supose to be 4,000 kb if an int weighs 32 bits.
another thing worth mentioning is that I am using ctrl + altk + delete method to check out how much space my program is taking from the ram and i'm running it on visual c++ 2010 express.
I am also positive that an int on my pc is 32 bits and not 64 not that it matters anyways because even if it were to be 64 and not 32 it should of been 8,000 kb and not 32,000 kb.
so maybe you can try to do this on your pc and tell me if you have the same results.
If you know where I went wrong please tell me.
4-byte chunks of memory are too small to be worth managing. There are also possible performance penalties associated with giving potentially unrelated chunks of code objects that share a cache line.
Typical memory managers have a minimum chunk size of somewhere between 16 and 256 bytes. Also, some overhead is typically needed to track the fact that a chunk of a particular size has been allocated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With