I encountered an out of memory exception a few hours after the report was run:



I found in SM04 that my report consumes more and more memory as time goes by:





How do I find the exact location of the code in memory leak? There is a package size in my report, which is similar to the design of OPEN CURSOR and FETCH. For example, if the package size is 1000, the buffer will be cleared once every 1000 service orders are successfully created. Then create the second batch of 1000 orders and clear the second buffer. Therefore, I only need to create a memory snapshot after the two cleaning buffers:

Once created, the tcode S_MEMORY_INSPECTOR compares the delta parts in the two snapshots, which are the variables causing the memory leak. This transaction lists the program name of the variables, and all that remains is to find the API to clean up the corresponding variables.

The consumtpion was over 7GB for one hour of user session running, and now the consumtpion is no more than 2GB for one afternoon running.

For more of Jerry’s original articles, please follow the public account “Wang Zixi “: