1

I have problems with file operations, that when I use the $M compiler command, that file operations "sometimes" not work. They do nothing. When I remove the $M command, than EXEC do nothing and the file operation make "NO" problems.

Sorry, I have problems with recreate the error. Have anyone a idea, why?

{$M 4000,0,0} {Do not work without this compiler command to use the the EXEC}

uses dos, windos;

begin
SwapVectors;
Exec('c:\command.com', '/c dir');
SwapVectors;

{When I use file operation, it do nothing}
{File operations do not work with the $M 4000,0,0 compiler command}
{Why?, I need both}

{ ex. assign, fileattr, reset, close }

end.

1 Answer 1

2

$M in combination with exec mostly means minimizing available memory to the running program to maximize memory in favour of the child program.

The syntax is {$M stack size, heapmin, heapmax} so you keep a small stack but deny all heap usage. So probably something in the RTL does dynamic memory allocation and that fails then. It is not an on/off measure, you need to tune it between your main program's memory needs and the child process spawned wit EXEC()

Note that doing it this extreme should not be necessary for a simple dir.

It can also point on bad configuration of the dos system that somehow leaves too little conventional memory.

Sign up to request clarification or add additional context in comments.

5 Comments

Yes, it give more problems when I start larger programs then 100kb or higher. Is there an other way or command to start an application? ex. Inline-Assembler?
Either do less in your main application, or cut memory to sub applications. In 32-bit compilers (like the dos/go32v2 version of Free Pascal) this problem goes away.
Is with Borland Turbo c/c++ the same problem?
I don't know, never use Turbo C++ much, but it might have more advanced memory models. But 16-bit is pain either which way.
The Free Pascal 16-bit compiler also supports huge memory model iirc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.