VOGONS


First post, by vstrakh

User metadata
Rank Member
Rank
Member

It seems that Turbo Debugger version 5.0 will take all the XMS available. Well, it's not the TD really but the DPMI host TD is using.
Is there a way to limit the allocation for DPMI host / RTM?
I found old manuals on bitsavers, the TD 2.0 and 2.5 had the -e command line switch that tells how much extended memory to leave for the application. But the version 5.0 rejects this switch as invalid.

So, is there are way to limit XMS usage by the TD's environment, other than allocating XMS with another program upfront, and then releasing it at the beginning of the program in order to debug allocation-related code of the app?

Reply 1 of 2, by vstrakh

User metadata
Rank Member
Rank
Member

Oh, found the answer in the articles not directly related to TD, but using same Borland DMPI host.
The host checks the DPMIMEM environment variable. Setting it to "MAXMEM xxx" limits the host to that xxx amount of kB's, so the extended memory remains available for the debugged application.

Reply 2 of 2, by vstrakh

User metadata
Rank Member
Rank
Member

The story continues on 286 pc.

The newer TD 5.0 does not run on 286, with the issue buried in the dpmi16bi.ovl not recognizing my machine. I've ran the dpmiinst, it did some tests and altered the DPMI server internals, but TD still did not run. So I've tried earlier Turbo debugger v3.2. It has separate versions for real mode, 286 protected mode, and 386 virtual mode debuggers.
The real mode TD.EXE does not use XMS but eats up lots of conventional memory. The TD386 obviously does not run on a 286 pc 😀

Now the TD286 embeds its own protected mode management stuff, and has its own td286inst.exe, very much the same as there is dpmiinst.exe for dpmi16bi.ovl, which is not used by TD286.EXE.
Since it's not the DPMI extender, it doesn't look for environment variables, and the debugger has no switches to reserve XMS for application, like in TD386.

I've looked into td286 with Hiew to find the spots where I could patch in the code that will limit the XMS allocations. The final solution was even easier than I thought.
The TD286 protected mode manager does not really allocate every bit of extended memory, it only grabs the largest contiguous block. So the easiest way to prevent it from allocating the whole xms memory is to fragment it 😀
I wrote a tiny app that allocates half of the extended memory, then allocates smallest block possible (1KB), and then release the previously allocated large block. That tiny block is then simply left dangling, not being used for anything but causing the memory fragmentation, so now TD286 will grab only one of two large blocks available, leaving the rest for the applications.

Note that fragmentation only works for TD286 with its rudimental memory handling.
This does not work for TD that uses DPMI host, apparently it's more advanced and can stitch scattered physical memory blocks into one contiguous virtual address space.