Re: [Plib-devel] Memory leaks, was: GL_COLOR_MATERIAL pitfall
Brought to you by:
sjbaker
From: <Va...@t-...> - 2000-05-01 13:33:51
|
Wolfram Kuss wrote: > > Christian wrote: > > >Even the old DOS freed the memory. > >(To get sure I just wrote a program that allocated 1 MB and didn't free > >it. As soon as it quit itself the memory was freed) > > Thats interesting. > Did you really run it under pure DOS or under the shell of Win NT/ > Win 95/Win 2000? I've compiled #include <conio.h> void main(void) { char *c; c = new char[1000000]; while ( getch() != 'q' ) ; } as a Win32 console app. When I run it under Win2k I see how about 1.5 MB RAM 'goes away' and as soon as I hit q it reappears. Ditto under Win 95 (DOS shell) I was curious about DOS now so I looked it up. When you asked DOS directly for RAM (calling the MS-DOS interrupt 0x21(?) with 0x48 in AH) it would be allocated till the next restart or you'd free it (AH = 0x49). But as the C-compilers allocated the memory on their heap and the heap got freed when the program terminated you wouldn't get a leak. So I was wrong about DOS (but not about normal programms that were running under DOS). > BTW, does DOS use the MMU? > The main disadvantage of the Amiga was that the OS didnt use a MMU, > even if one was present. The Amiga taught you about freeing things. If the MMU is the posibility of the CPU to lock RAM pages and call an interrupt/exception if an programm wants to access such a locked page (e.g. it's locked as the memory content is swapped or used by a different program) then it's not used by DOS as it's using the real mode (it only knows the 640 kb). But there are DOS extenders (e.g. EMM32 and some others) that switch the CPU to the protected mode and make it look like it's still running the real mode. Only these programs let you access more than the 640 kb RAM under DOS. You'd tell them that you need xx byte RAM, they allocate it for you and then you'd give them an address in the first 640 kb that contains the data and the extender copies it then to the extended RAM. (This is all of the top of my head; I could look up the details - but I gues noone really cares anymore) Thank god that the 16bit days have gone!! CU, Christian |