cancel
Showing results for 
Search instead for 
Did you mean: 

Memory Analysis

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

naimesh_patel
Active Contributor
0 Kudos

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

matt
Active Contributor
0 Kudos

Surely this is not a deep structure. It looks flat to me. A deep structure is one containing an inner table, isn't it?

naimesh_patel
Active Contributor
0 Kudos

This is definitely deep structure as the field LINES is the standard table. That makes the structure as deep structure. Even debugger recognize that as a deep structure.

Thanks,
Naimesh Patel

matt
Active Contributor
0 Kudos

I stand corrected sir. I missed that bit!

Answers (0)