[Yabasic-users] Malloc problem, Yabasic under Windows 98
Brought to you by:
psnake,
thomaslarsen
From: Steve L. <ste...@ho...> - 2001-03-30 16:07:55
|
Hello everybody, A few days back, I posted a question about a problem I have encountered. Under Windows 98, yabasic cannot handle large numbers of subroutine calls with large numbers of parameters. Virtual memeory is gradually eaten up, and eventually the program fails with a malloc error. I have found that the problem also happens if large numbers of subroutine calls are made and there large numbers of local variables declared within the subroutine. My programs call many different subroutines, each with a few local variables. The algorithm is repeated a few hundred thousand times (its an optimisation program for a multi-variable problem). I can reproduce the problem with a simple piece of code which uses a single subroutine, called a few million times. To show the fault more quickly, you can set the upper limit for your virtual memory to say 300Mb. On my PC, that means the the problem happens after only 75,000 subroutine calls. Has anybody else seen this problem with local variable space not being released? How do I resolve it? Thanks, Steve >>>>>>> REM REM Some preliminary tasks REM clear screen:open window 100,30:window origin "lb" REM REM To demo the problem, we must call a function many times REM for Counter = 1 to 10000000 DoSomeWork() REM REM Display the loop counter so that we can see how far the program has got REM clear window text 10,10, str$(Counter) next Counter REM REM Tidy up and finish. If the fault happens, the user never gets this far.... REM inkey$():close window sub DoSomeWork() local a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1,l1,m1,n1,o1,p1,q1,r1,s1,t1,u1,v1,w1,x1,y1,z 1 local a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z 2 local a3,b3,c3,d3,e3,f3,g3,h3,i3,j3,k3,l3,m3,n3,o3,p3,q3,r3,s3,t3,u3,v3,w3,x3,y3,z 3 local a4,b4,c4,d4,e4,f4,g4,h4,i4,j4,k4,l4,m4,n4,o4,p4,q4,r4,s4,t4,u4,v4,w4,x4,y4,z 4 local a5,b5,c5,d5,e5,f5,g5,h5,i5,j5,k5,l5,m5,n5,o5,p5,q5,r5,s5,t5,u5,v5,w5,x5,y5,z 5 local a6,b6,c6,d6,e6,f6,g6,h6,i6,j6,k6,l6,m6,n6,o6,p6,q6,r6,s6,t6,u6,v6,w6,x6,y6,z 6 local a7,b7,c7,d7,e7,f7,g7,h7,i7,j7,k7,l7,m7,n7,o7,p7,q7,r7,s7,t7,u7,v7,w7,x7,y7,z 7 local a8,b8,c8,d8,e8,f8,g8,h8,i8,j8,k8,l8,m8,n8,o8,p8,q8,r8,s8,t8,u8,v8,w8,x8,y8,z 8 local a9,b9,c9,d9,e9,f9,g9,h9,i9,j9,k9,l9,m9,n9,o9,p9,q9,r9,s9,t9,u9,v9,w9,x9,y9,z 9 REM REM ....here is where we would normally do lots of work.... REM end sub |