Help: Not enough memory while trying to exec with egavga.bgi loaded... 
Author Message
 Help: Not enough memory while trying to exec with egavga.bgi loaded...

[--snip--]

Quote:

>The problem is that when the exec procedure is called it returns a Dos
>error of 8 (not enough memory), or if the {$M $4000,0,0 } etc command
>is used as suggested in the help file the program will not run giving
>the error that not enough memory to load the bgi driver. I would be
>grateful if any one has any suggestions on how to free up the right
>amount of memory & heap to get both routines running together.

Rob, the three numbers following the $M option are stack, minimum heap,
maximum heap.  As you have it, you've defined a 16k stack and no heap.
Depending how you've put the program together, you may be loading the
bgi driver into the heap.  In addition it needs to take a chunk of heap
for a working buffer.  I believe the default buffer is about 4k.

I'd suggest starting with at least a 16k heap.  {$M $4000,$4000,$4000}
and experiment from there.  If memory is tight, you might want to take
another look at your stack requirements, 16k sounds like it may be a
lot more than you need.  Regardless, I believe you will find that you
can get the graphics working and still have a reasonable amount of
memory free.

You could also use an EXESWAP unit such as the one available from
TurboPower.  That would allow your program to release all but about 6k
of memory by writing its image to disk using ExecWithSwap.

                      ...red

Knowledge is one of the few things that you
can give away and still keep for yourself.



Wed, 18 Jun 1902 08:00:00 GMT  
 Help: Not enough memory while trying to exec with egavga.bgi loaded...

Quote:

>Hi People,
>        I've been reading this group for a couple of weeks now and
>have found it very interesting and valuable learning support. I am a
>student but the problem is with a personal project not an assignment
>etc. I'm using Borland's Turbo Pascal ver7.0 under MSDOS ver7.0.
>[...]
>The problem is that when the exec procedure is called it returns a Dos
>error of 8 (not enough memory), or if the {$M $4000,0,0 } etc command
>is used as suggested in the help file the program will not run giving
>the error that not enough memory to load the bgi driver. I would be
>grateful if any one has any suggestions on how to free up the right
>amount of memory & heap to get both routines running together.

The BGI system needs some heap space in order to load BGIs and do some of
its work.  The above directive {*filter*}s it by not allowing any heap at
all.  OTOH, if you don't specify heap usage, the default is usually to use
all available memory as heap, which doesn't leave any memory if you need to
access DOS.

Try increasing the third value to give more heap space.  Try

{$M $4000,0,131072}

This will give you 128K or heap space for the BGI system to use, and the
rest of your conventional memory will be available to DOS.  If you still
have problems, try increasing the number.  Try to increase by values that
are based around 2^n, such as 16384, 32768, or 65536.

Quote:
>I have tried my course tutor for help and he suggests that I run the
>program in text mode, but I have put quite a lot of work into the
>current menu & graphics and as it is a personal project I don't get a
>lot of time to play with it (lots of assignments).

When you do have the time, pick up your Language Guide and read about the
heap manager to see how memory is used in a TP program.

Quote:
>As far as physical memory limitations go, I have 64mb of RAM of which
>approx 630kb of conventional is available, I'm using Qemm ver 8.0 and
>have a large number of set commands in the autoexec.bat which use up a
>lot of environment space.

This is all mostly irrelevant.  TP only produces real mode programs, which
can access only the lower 1MB of memory directly (which may also be
emulated as a virtual machine under a Win 3.x/Win 95 DOS session).

Quote:
>Let me know if you need the source posted as Ieft it out to make the
>message a bit smaller, just in case it was something really simple I
>was missing.

No, I think my suggestion may solve your problem.

Quote:
>                Thanks in Advance for any help.
>                                                Rob

--
Scott F. Earnest           | We now return you to our regularly scheduled

NOTICE:  This address will cease to exist as of 19 May 1996, and is not
currently reliable for e-mail.  Please address replies to



Wed, 18 Jun 1902 08:00:00 GMT  
 Help: Not enough memory while trying to exec with egavga.bgi loaded...

Hi People,
        I've been reading this group for a couple of weeks now and
have found it very interesting and valuable learning support. I am a
student but the problem is with a personal project not an assignment
etc. I'm using Borland's Turbo Pascal ver7.0 under MSDOS ver7.0.

The program is a simple menu application that lets a user select one
of 20 options by using the up and down arrow keys and return. Most of
the options are required to run an exec procedure and basically
execute PKUNZIP or ARJ with the passed command line. Other options
just display help screens, info screens etc. Graphics mode using
egavga.bgi is initialised as the example given in Borlands help and a
few routines borrowed from the SWAG archives are used.

The problem is that when the exec procedure is called it returns a Dos
error of 8 (not enough memory), or if the {$M $4000,0,0 } etc command
is used as suggested in the help file the program will not run giving
the error that not enough memory to load the bgi driver. I would be
grateful if any one has any suggestions on how to free up the right
amount of memory & heap to get both routines running together.

I have tried my course tutor for help and he suggests that I run the
program in text mode, but I have put quite a lot of work into the
current menu & graphics and as it is a personal project I don't get a
lot of time to play with it (lots of assignments).

As far as physical memory limitations go, I have 64mb of RAM of which
approx 630kb of conventional is available, I'm using Qemm ver 8.0 and
have a large number of set commands in the autoexec.bat which use up a
lot of environment space.

Let me know if you need the source posted as Ieft it out to make the
message a bit smaller, just in case it was something really simple I
was missing.
                Thanks in Advance for any help.
                                                Rob



Wed, 18 Jun 1902 08:00:00 GMT  
 Help: Not enough memory while trying to exec with egavga.bgi loaded...


:The problem is that when the exec procedure is called it returns a Dos
:error of 8 (not enough memory), or if the {$M $4000,0,0 } etc command
:is used as suggested in the help file the program will not run giving
:the error that not enough memory to load the bgi driver. I would be
:grateful if any one has any suggestions on how to free up the right
:amount of memory & heap to get both routines running together.

-From: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip Frequently Asked TP Questions
-Subject: TP program memory requirement

68. *****
 Q: How much memory will my TP program require?

 A: Get MAPMEM.EXE from ftp://garbo.uwasa.fi/pc/memutil/tsrcom35.zip
and put the following code within your Turbo Pascal program:
  Program faq;
  uses Dos;
  :
  SwapVectors;
  Exec (GetEnv('comspec'), '/c mapmem');
  Swapvectors;
Then you'll see a MAPMEM output something like this
  Psp  Cnt   Size Name       Command Line        Hooked Vectors
  ---- --- ------ ---------- ------------------- --------------
        2  26,896 DOS
  0694  2   3,392 COMMAND                        2E
        1      64 ---free---
  0776  2   1,488 MARK       scrollit
  07D6  2  70,816 FAQ                            FF
  1923  3   2,752 command                        22 23 24
  19D2  2 549,712 ---free---
          655,344 ---total--
The memory requirement of your program FAQ.PAS is 70,816. Do not
confuse this figure with the physica size of your program. The
memory requirement affected among other things by the Memory
Allocation Sizes Directive. For example you might have
{$M 16384,0,50000}

-Date: Sun, 12 Jun 1994 10:22:18

-Newsgroups: comp.lang.pascal
-Subject: Re: How much memory will my TP program require?

   I think this is a hard question, and probably needs a longer
answer than you gave.  Yours isn't quite right, because TP will
allocate memory that it doesn't need if you set the heapmax
parameter too high.  Your program will run in less memory than
MAPMEM reports. Here's a quick attempt at it:
   TP DOS programs use memory in 4 or 5 blocks:  fixed code, static
data, the stack, sometimes overlaid code, and the heap.  TP Windows
programs add a local heap to this list, but don't use overlays.  The
discussion below deals with real mode DOS programs.
   The size of the code is determined by which procedures and
functions you use in your program.  In DOS, if you don't use
overlays, this is all fixed code, and the size is reported as "Code
size" in the Compile| Information listing in the IDE.  The ways to
reduce it are to use fewer procedures or make them smaller, or move
them to overlays.
   Static data consists of all the global variables and typed
constants in every unit.  It is reported as "Data size" in the
Compile|Information listing.  You can reduce it by declaring fewer
or smaller variables.
   If you use the $O directive to move code to overlays, then those
units won't count as part of your fixed code needs.  You will need
an overlay buffer at run-time; by default, it's the size of the
largest unit you use, but normally you'll change the size with
OvrSetBuf.  It's difficult to work out the best size of this block
except by trial and error:  if your program spends too much time
swapping, then make it larger; if you run out of memory, make it
smaller.  You'll need to use the .MAP file (see the Options| Linker
dialog to create one) to find the size of each unit.  Remember to
subtract the size of overlaid units from the reported "Code size"
when working out the size of fixed code.
  The stack is used for local variables in procedures.  Its size is
controlled by the first parameter to the $M directive; the default
size is 16K.  It's hard to predict exactly how much stack space your
program will use.  One way is to keep reducing the value until your
program aborts with a stack overflow, then use a slightly larger
value.  Another way is to fill the stack with a fixed value at the
start of your program, and at the end, see how many values were
changed.  Again, it's a good idea to allow for a margin of safety,
because hardware interrupts will use this space, and their size is
hard to predict.
   The heap is where New and Getmem get their allocated memory.  The
size is controlled by the 2nd and 3rd parameters to the $M
directive.  The heapmin value will always be allocated; if extra
memory is available, your program will ask for as much as possible,
up to heapmax.  If not enough memory is available to load all your
fixed code, data, stack and heapmin, DOS will refuse to load your
program.  You have nearly complete control over the size of the heap
that you need, determined by how much you use New and Getmem. The
only exception is that some of the standard units use heap space;
GRAPH and all the TurboVision units are examples.  To find how much
your program actually uses, you can reduce Heapmax until it fails,
fill the heap with a special value and look for changes, or monitor
the value of HeapPtr as your program progresses.
--------------------------------------------------------------------

   All the best, Timo

....................................................................

Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa



Wed, 18 Jun 1902 08:00:00 GMT  
 Help: Not enough memory while trying to exec with egavga.bgi loaded...

the problem is with a personal project not an assignment

Quote:
> etc. I'm using Borland's Turbo Pascal ver7.0 under MSDOS ver7.0.

> The problem is that when the exec procedure is called it returns a Dos
> error of 8 (not enough memory), or if the {$M $4000,0,0 } etc command
> is used as suggested in the help file the program will not run giving
> the error that not enough memory to load the bgi driver. I would be
> grateful if any one has any suggestions on how to free up the right
> amount of memory & heap to get both routines running together.

> I have tried my course tutor for help and he suggests that I run the
> program in text mode, but I have put quite a lot of work into the
> current menu & graphics and as it is a personal project I don't get a
> lot of time to play with it (lots of assignments).

> As far as physical memory limitations go, I have 64mb of RAM of which
> approx 630kb of conventional is available, I'm using Qemm ver 8.0 and
> have a large number of set commands in the autoexec.bat which use up a
> lot of environment space.

   Are you doing all this in the IDE?  If so, no matter how you set the
Heap_Max parameter in the $M parameter, most Exec calls of any substance
won't work...producing the result you're getting.  That fact is, the IDE
and optimal use of Exec are mutually excsluive, since the IDE editor,
linker, source code, etc. consume so much of the Real Memory you have.
   There are several ways to deal with this.  First, lose that "IDE
dependance" - compile the program(s) to EXE (compile to Disk, use TPC,
Make, whatever) file(s) and execute as DOS program(s).  IMHO, extreme
overreliance on doing everything in the darn IDE has evolved, and people
can't seem to do without it - I don't use it _at_all_, and I've written
almost 700,000 lines of TP code in the last 12 years...it can be done.
   Next, if that doesn't work - and I can't see how what you describe
wouldn't - you can acquire and use one of the PD "swapping Units", which
swap out most of you program whenever an "Exec" call is made.  Packages
such as ExecSwap (the one I use), SPAWN, ExecWSwp, and others are freely
available and will do a nice job for you - for extreme spawning needs.


Wed, 18 Jun 1902 08:00:00 GMT  
 Help: Not enough memory while trying to exec with egavga.bgi loaded...


Thanks to both Scott F. Earnest and R. E. Donais for your help. I
managed to solve the problem by using a small assembly routine I found
while browsing the SWAG archieves. In case any one else is interested
the said routione is as :-

(***************************************************************************)

Function DosShell(ProgName:String; CommandLine:String):Integer;

Var
 OldHeapEnd,
 NewHeapEnd: Word;
 Error:Integer;
Begin
 Error:=0;
 If MemAvail<$1000 then Error:=8;
 If Error=0 then Begin
  NewHeapEnd:=Seg(HeapPtr^)-PrefixSeg;
  OldHeapEnd:=Seg(HeapEnd^)-PrefixSeg;
   asm
    mov ah,4Ah
    mov bx,NewHeapEnd
    mov es,PrefixSeg
    Int 21h

    mov Error,ax

   end; {asm}
  If Error=0 then begin
   SwapVectors;
   Exec(ProgName,commandline);
   SwapVectors;
    asm
     mov ah,4Ah
     mov bx,OldHeapEnd
     mov es,PrefixSeg
     Int 21h

     mov Error,ax

    end; {asm}
  end;   {If}
 end;    {If}
 DosShell:=Error;
end;     {Function}

(***************************************************************************)

As far as I know the routine creates a temporary heap which is used to
complete the exec procedure after which the original heap is returned.

        Thanks again for your help guys.
                                                Rob.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. not enough memory to load driver (error -5)

2. Does egavga.bgi not work on FAT32?

3. egavga.bgi file not found

4. EGAVGA.BGI not found in network env.

5. Not enough Memory BDE Error

6. Not enough memory for the graphics!

7. Error msg: Not enough memory...

8. BDE - failure (not enough memory)

9. Not enough Handles - help

10. Egavga.bgi

11. Using EGAVGA.BGI - How to program the screensaver - scrnsavr.pas (0/1)

12. Using EGAVGA.BGI - How to program the screensaver - scrnsavr.pas (1/1)

 

 
Powered by phpBB® Forum Software