on 07-29-2014 4:45 PM
Hi Experts,
ISSUE PART 1
i have created two structures ZTEST_SRC and ZTEST_TRT. The structure ZTEST_TRT contains the same fields as in structure ZTEST_SRC but i have removed the include COMT_TEXT_TEXTDATA in this structure.
Technically, as the two structure contains the same fields and length, the memory occupied during run time should be same.
But contrary to the expectations, its not .
I have written a short program to analyze it. Please find the screen shot below.
***************************************************************************************
REPORT ZTEST_COMPARE_LENGTH.
DATA: SRC TYPE ZTEST_SRC,
TRT TYPE ZTEST_TRT,
LO TYPE REF TO CL_ABAP_TYPEDESCR,
LSRC TYPE REF TO CL_ABAP_TYPEDESCR,
LTRT TYPE REF TO CL_ABAP_TYPEDESCR.
DATA: REF_KIND TYPE CHAR10,
STXH TYPE STXH,
LINES TYPE COMT_TEXT_LINES_T,
FUNCTION TYPE TDFUNCTION.
CALL METHOD CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA
EXPORTING
P_DATA = SRC
RECEIVING
P_DESCR_REF = LSRC.
CALL METHOD CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA
EXPORTING
P_DATA = TRT
RECEIVING
P_DESCR_REF = LTRT.
BREAK-POINT.
***************************************************************************************************************************
During debugging, the following is the screenshot of the memory analysis.
The bytes occupied by SRC is 912 and TRT is 904.
ISSUE PART 2:
Now i have changed the filed length of the field 'REF_KIND' in both the structures to CHAR80.
Now i have execute the program and here is the memory analysis.
Surprised to see that the Bytes occupied are 928 and its same.
Why is memory occupied not the same in ISSUE PART 1 when char70 is used for field REF_KIND as in ISSUE PART 2 ?
Hope I have provided sufficient data for analysis and I need your help in getting to know about it.
Thanks in advance.
Cheers,
Ravi.
'RE
Hello Ravi,
I modified your code and ran several test. I capture the details on how the memory allocation could be when there are different objects in the structure at ABAP Memory Allocation - Why extra 8 bytes!
The different in the memory allocation is due to how SAP assigns the memory to the variables. The same difference of 8 bytes can be seen with REF_KIND as CHAR1 or CHAR2 or CHAR3. When it is multiple of 4, you notice that both of them are same.
The difference of 8 bytes could be due to the deep structure. I think SAP assigns the memory in blocks of 8 bytes when there are deep objects in the structure. In case of SRC, it has the included type as well. I believe, SAP assigns the memory from inner most to outer. That means, it would allocate the memory to all the objects of the included type, convert them to blocks and allocate the memory to the remaining flat types.
Thanks,
Naimesh Patel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.