Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

real mode memory management question (Developers)

posted by marcov, 25.08.2008, 10:51

> Memory requested by malloc and later freed by free won't be given back to
> DOS instant and therefore you are out of ram pretty fast because the
> memory becomes only available again after the exe terminated?
>
> Can I somehow force to flush the memory to the operating system so I can
> request it again for other tasks?

If you use the system malloc in the default setup, this will be very hard. Why? After a bunch of mallocs the whole memory is fragmented like a big cheese. So even while e.g. half of the mem is still free, there is no contiguous block of that size that is free at the end of the memoryspace.

So that means you will have to limit your heap, and/or manually administer it, so that the parts that you free before doing (what I assume is shelling) are really free in one contiguous block. Then you can probably call some sbrk() a like to shrink the datasegment and shell.

Somewhat fancier is to swap the entire real mode mem to ems before shelling, but that means undoing any callbacks you have installed (e.g. interrupt vector fiddling)

In the 32-bit case, this could be easier, since then you can simply not use the dos 640k much, and extenders often already allow to swap the remaining content out, except for some core extender interrupt handlers. Is your watcom 32-bit or 16-bit?

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 127 users online (0 registered, 127 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum