[comp.windows.x] Cannot perform realloc -- Questions

ecollins@NMSU.EDU (07/24/90)

I have a good sized Athena Widget based program which creates
toplevelshells for things such as help and various other options.  If
I select one of these options as soon as the initial screen comes up
then the toplevelshells are created and everything works fine.

If I do some text processing ( including message passing with a Prolog
process using named pipes ) and then try to use one of the options
that generate a new toplevelshell I get the following message:

Error: Cannot perform realloc.

Sometimes I get the error, sometimes I don't, but typically I'll get a
core dump at this point. If I don't select a toplevelshell option the
program runs fine.  I only allocate memory dynamically in one place
and I'm sure that I free it properly when I'm done with it. I find it
hard to believe that I'm running out of virtual memory.

My questions are:

0.  Since this happens the first time I try to use an option that
    creates a toplevelshell ( after other processing takes place ) why
    is realloc being used instead of malloc or another alloc proc? 

1.  Is there a way to programmatically monitor the available free
    memory as I execute the program so that I can see where memory
    is being used up?  How?

2.  I'm declaring several large character arrays inside lower level 
    functions.  Is it more memory efficient to declare these as global
    static arrays rather than auto arrays local to the function?

3.  Are there certain types of programming errors that typically cause
    the above problem?

4.  Is it possible to install an error handler so that this is not a
    fatal error?

Any help would be greatly appreciated.        

Mike Collins.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=  Mike Collins                   | "Why would I want to change my    =
=  New Mexico State University    |  mind?  Is there something wrong  =
=  e-mail: ecollins@nmsu.edu      |  wrong with the one I have?"      =
=                                 |  -- Mr. Spock                     =
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=