Page 1 of 1

Maximum limit for dynamic array allocation

Posted: Wed Nov 07, 2012 4:28 pm
by kaverisowmiya
We have declared the array like below one,

DCL A FIXED BIN(31) INIT(0);
DCL I FIXED BIN(31) INIT(0);
DCL AY(*) CHAR(1) CONTROLLED;

A = 2147483647;
FREE AY;
PUT SKIP LIST('BEFORE ALLOCATE');
ALLOCATE AY(A) CHAR(1);
PUT SKIP LIST('AFTER ALLOCATE');
DO WHILE (I <= 2147483647);
I = I + 1;
AY(I) = 'M';
END;
PUT SKIP LIST('I',I);
FREE AY;

and we got the following error in run time
********************************* TOP OF DATA **********************************
IBM0451S ONCODE=451 The STORAGE condition was raised.
From entry point SAMPLEM at compile unit offset +00000136 at entry offs
******************************** BOTTOM OF DATA ********************************

While checking for maximum array indexing , we got the limit of 2147483647 but its not working when we tried to allocate dynamically or by static.

Please provide us your suggestions

Thanks in advance!!!

Posted: Wed Nov 07, 2012 5:07 pm
by William Collins
Why can't you let us in on which line caused the problem?

You test for <= 2147483647 and then you add one right afterwards.

Are you going to do that loop often?

Posted: Thu Nov 08, 2012 10:44 am
by kaverisowmiya
The program got abend before allocation itself, its not allocating the maximum index for array :(

Posted: Fri Nov 09, 2012 1:56 am
by DikDude
Is there some reason you did not answer the questions :wink:

If you want help, you need to humor the helpers and answer their questions . . .

Posted: Fri Nov 09, 2012 1:59 am
by NicC
If the abend happened BEFORE the allocation statement then why do you think the allocation statement is causing a problem? Which statement is at offset 136? Did you get your diagnostic 'BEFORE ALLOCATE' in your SYSPRINT. If not then either your did not even get that far or the abend was after BUT you need to double up on your PUT SKIP to ensure it comes out.