Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!mcsun!tuvie!vmars!hp From: hp@vmars.tuwien.ac.at (Peter Holzer) Newsgroups: comp.lang.c Subject: Re: system() command Message-ID: <2310@tuvie.UUCP> Date: 9 Feb 91 21:16:42 GMT References: Sender: news@tuvie.UUCP Lines: 74 tp1l+@andrew.cmu.edu (Thomas W. Pope) writes: > I am writing a short program to put into my autoexec file, allowing me >to select a shorter autoexec by hitting a key. For this I tried to use the >system() command to run either of two batch files. The command works fine, but >the program stays resident after that call, adding 64k to my memory usage. > The Turbo C manuals say that the system command will run batch files fine, >but it seems to terminate withour clearing memory every time I try it... Does >anyone know how I could make these calls from my program??? I have tried the >following calls: > system(default) system(call default) Shouldn't this be: system ("default"); and system ("call default"); ? Apart from that, does your batchfile invoke any TSRs? If it does, it will fragment your memory, and DOS will report only the largest chunk as free memory, although it can use the rest as well. Your memory looks something like that (low addresses at the bottom: Command.com DOS Start your program: yourprog.exe Command.com DOS system ("default"): command.com -c default yourprog.exe Command.com DOS default now executes some TSR, e.g. sidekick: sidekick command.com -c default yourprog.exe Command.com DOS default terminates, thus command.com and system terminate, too: sidekick yourprog.exe Command.com DOS Then your program terminates: sidekick Command.com DOS So you have sidekick floating around somewhere in mid-memory, with a whole of ~64kB below it and a larger hole above it. DOS will always use the largest available whole and it cannot split a program to use multiple wholes so you have wasted those 64kB :-(. -- | _ | Peter J. Holzer | Think of it | | |_|_) | Technical University Vienna | as evolution | | | | | Dept. for Real-Time Systems | in action! | | __/ | hp@vmars.tuwien.ac.at | Tony Rand |