First, let us look at what really happened when we run our application inside SAP. Once a certain transaction has been triggered to run (inputting the tcode for example), it will automatically consume a different memory allocation from variable declarations, calling db tables, creating an object and so on. These memory allocations will be retained and compounded ( pressing f8) as long as the transaction is currently active or has not been exited/terminated yet. I.e if you are running a report repeatedly by returning back to the selection screen and run it again and so on without terminating, then this will increase the memory being consumed in allocated addresses like heap, paging etc. Doing such, will result to a memory overflow until your current transaction will be forcefully terminated by the system. Of course, addressing this issue can be done by a proper, careful, and efficient program design.
Memory related problems i.e leaks, can be identified using STAD and SM04/SM50 tcodes of SAP.
STAD ideally used to detect resource consumption after running a transaction or has finished processing. While, SM04/SM50 is ideal for monitoring online, real-time or running transactions.
Using the ABAP debugger is also helpful in looking for memory consumptions of ABAP.
Initializing Internal tables to a specific number of records, if you're sure, and or initializing it to zero or using the new itab declarations i.e TYPE STANDARD TABLE are advisable. These will help significantly in addressing memory leaks. Other best practice approach is to use FREE/REFRESH and CLEAR statement to your variables or itabs. Remember that using DELETE doesn't decrease or eliminate memory allocations but rather only delete the records or data of your itab. Thus if a certain itab will not be used anymore, it is advisable to refresh the content to minimize memory leaks or to avoid it completely.
No comments:
Post a Comment