I have a program which fails like this:
---Fatal in test.txt,28: Can't malloc 32 bytes of memory
---Immediate exit to system, due to a fatal error
---Program done, press RETURN---
Has anybody else encountered this? Do you know how to prevent it?
My program is not complicated but it does take some hours to execute. I
noticed that the disk drive access light flashed all the time, even though
there is no file access in the program. Since malloc is the C construct for
dynamic allocation of memory, the continuous disk accesses made me suspect
that the Windows Swap file is being gradually filled up, eventually causing
the failure when the disk becomes full.
After some experimentation, I was able to produce a simple program to
demonstrate the problem (below). The program makes millions of calls to a
subroutine, each time passing a large number of parameters. The more
parameters there are, the sooner the program fails. Also, if I configure
Windows so that the maximum swap file size is smaller than usual, the
program fails sooner. With a maximum swap file of 300Mb, the program fails
after only a few hundred thousand iterations.
Thanks for any advice on how to resolve this problem,
Steve
>>>>>>>>>>>>>>
REM
REM Some preliminary tasks
REM
clear screen:open window 100,30:window origin "lb"
REM
REM To demo the suspected bug, we must call a function many times with
several parameters
REM
T1$ = ""
for C1 = 1 to 100000000
DoSomeWork(C1,T1$,T1$,T1$,T1$,T1$,T1$,T1$,T1$,T1$,T1$,T1$,T1$,T1$,T1$,T1$,T1
$,T1$,T1$,T1$,T1$,T1$,T1$,T1$,T1$)
next C1
REM
REM Tidy up and finish. If the fault happens, the user never gets this
far....
REM
inkey$():close window
sub
DoSomeWork(N,P1$,P2$,P3$,P4$,P5$,P6$,P7$,P8$,P9$,P10$,P11$,P12$,P13$,P14$,P1
5$,P16$,P17$,P18$,P19$,P20$,P21$,P22$,P23$,P24$)
REM
REM Display the loop counter so that we can see how far the program has
got
REM
clear window
text 10,10, str$(N)
REM
REM ....here is where we would normally do lots of work....
REM
end sub
|