popeye
10th May 2002, 01:06
Hi,
I am getting a fatal error while executing the alloc.mem()
command.

function main()
{
long ret
string ttr(1) based

ret = alloc.mem(ttr,3)
}

Thanks.
Cheers,
Popeye

~Vamsi
10th May 2002, 01:55
Popeye,

Just to let you know (that which you already know ;)) that your code works flawlessly on my system.

NPRao
10th May 2002, 02:28
I copied and pasted your code and it works fine to me too...

:rolleyes:

popeye
10th May 2002, 08:36
Why do you think I am getting the error?
Beats me :mad:
- popeye!

morpheus
24th April 2003, 15:30
Hey Popeye,
Did you get the solution for this error!? I am getting the same error in my script. The code seems to be OK. Any solution number or something for this!?

popeye
24th April 2003, 19:34
Hi,
I just tried the code, it's working fine now.

This was a long time back. I don't even remember posting this one :)
So ... I don't know how I solved this one.
Sorry about that.

Will let you know if I remember anything.
Cheers!

günther
28th April 2003, 08:13
hi popeye,

because of the missing free.mem(), any allocated memory will remain within the running bshell ("memory leak"). So if you run your example *very* often (because of 3 bytes), you will run into the mentionned problem.

I guess you made that small test program in a situation, where a real program had such a memory leak (alloc.mem with a large number of bytes, alloc.mem in a loop)?

And I guess, the problem disappeared after a logoff!

Günther

Hitesh Shah
2nd May 2003, 17:10
I supoose u have declared the variable in function main . And that's what is causing problem .

Declare the variable outside main . It should work.

morpheus
3rd May 2003, 06:42
No, the variable is defined outside the function.
Here is the sample code -


declaration:
string finish(1,1) BASED

function maintain.array()
{
inc = 10
temp = inc
alloc.mem(finish,8,inc) |*
count1 = 0
select tdcus605.fnsh
from tdcus605
group by tdcus605.fnsh
selectdo
count1 = (count1 + 1)
finish(1,count1) = tdcus605.fnsh
if ((temp - count1) = 1) then
alloc.mem(finish,8,inc) |**
temp = (temp + inc)
endif
endselect
}

function release.array()
{
free.mem(finish)
}


* 10 rows are allocated at this point.
** Another 10 rows should have been allocated here, but when 11th record is selected and stored, the mentioned error is thrown!!

Hitesh Shah
3rd May 2003, 08:32
I notice u never change the value of 'inc' variable used in alloc.mem .

U need to increment / decrement (if the functionality so requires) the variable in alloc.mem.

When you use alloc.mem another time, you should specify the total array size and not the size needed extra.

morpheus
3rd May 2003, 09:05
Thanks Hitesh, I notice that I did not increment inc in the script!!