鑑於網上這個資料實在太少,將之前整理過卻未徹底的一篇文章貼出來,但願大牛指正vs下內存管理方式。可聯繫gaoshiqiang1987@163.com函數
1 int _tmain(int argc, _TCHAR* argv[]) 2 { 3 char *pcMem = (char *)malloc(8); 4 short *psMem = (short *)malloc(12); 5 int *piMem = (int *)malloc(16); 6 long *plMem = (long *)malloc(20); 7 float *pfMem = (float*)malloc(32); 8 double *pdMem = (double*)malloc(48); 9 10 system("PAUSE"); 11 return 0; 12 }
pcMem 0x007722c8 "屯屯屯屯鉿鉿" char * psMem 0x00772310 short * piMem 0x00772358 int * plMem 0x007723a8 long * pfMem 0x00779230 float * pdMem 0x00779290 double *
0x007722B8 08 00 00 00 01 00 00 00 7a 00 00 00 fd fd fd fd cd cd cd cd cd cd cd cd fd fd fd fd ab ab ab ab 0x00772300 0c 00 00 00 01 00 00 00 7b 00 00 00 fd fd fd fd cd cd cd cd cd cd cd cd cd cd cd cd fd fd fd fd 0x00772348 10 00 00 00 01 00 00 00 7c 00 00 00 fd fd fd fd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd 0x00772398 14 00 00 00 01 00 00 00 7d 00 00 00 fd fd fd fd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd 0x00779220 20 00 00 00 01 00 00 00 7e 00 00 00 fd fd fd fd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd 0x00779280 30 00 00 00 01 00 00 00 7f 00 00 00 fd fd fd fd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd
7a--char 7b--short 7c--int 7d--long 7e--float 7f--double
至於還有結構體以及類的分配可能須要另外討論this
注1:這裏寫16byte是由於對比了分配內存首地址往前偏移8byte、16byte、32byte,發現16byte內存內容跟所分配的最接近,由於沒有源碼,因此只能作如上猜想spa
注2:沒有實際資料證實,只是猜測,上面幾個是基本數據類型,可是面對結構體或者類時其怎麼表示尚不清楚操作系統