In addition to realizing the functions of the common application system, the security system in smart grid also needs to ensure the security of the resources it manages, including confidentiality, integrity and availability. Compared with other programming languages, C++ is closer to the bottom layer of the operating system, and some underlying algorithms with high performance requirements need to be implemented. At the same time, because C++ can directly control the allocation and use of system resources, it has laid hidden trouble for memory leakage. In this paper, a memory leak detection method based on data flow analysis in power grid operating system is proposed. The main research objective is to extract the data flow of the object code or source program, and use the data flow to analyze it, and realize the memory leak detection. The experimental results show that the proposed method can effectively detect the memory leak caused by the improper use of C++ pointer, and has practical significance in the aspects of automatic test and static program detection.