Date: Mon, 19 Jun 1995 17:36:12 +0100 From: "Juan I. Perez" To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Counting Memory Problem I've got a problem with the dynamic allocation of structures. I've written a program in which I reserve memory for 4 structures (struct s_elto). The problem comes when I compare the memory I wanted to reserve, and the memory free of the computer (with the dpmi functions). This is the code: #include #include #include #include #include #include #define tam_memo 10240 struct s_elto { int memo[tam_memo]; }; struct s_elto *elto_crea(void); void elto_destruye(struct s_elto *elto); #define num 4 struct s_elto *elto[num]; int num_eltos=0; void main(void) { int i, pm; _go32_dpmi_meminfo meminfo; for(i=0;imemo)=%d\n",sizeof(elto[i]->memo)); printf("sizeof(elto[i]->memo[0])=%d\n",sizeof(elto[i]->memo[0])); } for(i=0;imemo)=40960 sizeof(elto[i]->memo[0])=4 As it can be seen, the struct elto needs 40960 bytes for been allocated, but the physical memory decrements only in 4092 bytes. Why? I'd be very grateful if anybody could help me. Thanks in advance. And another question: When I free memory, the physical memory available of dpmi function doesnït increase. Could anyone tell me why, please? Thanks again. *---------------------------* * Juan I Perez * * Zaragoza (Spain) * * e-mail:jips AT sol DOT unizar DOT es * *---------------------------*