Deformation memory effect (DME) is one of the rock memory effects. One important application of the DME is to determine the in situ stress. The in situ stress measurement methods based on the DME are commercial and permit large number of measurements. Application of DME needs the reliable and effective identification methods to detect the DME. However, the existing identification methods are insufficient and not distinct. In this paper, a new method based on fractal dimension was proposed. It takes advantage of the increase of the irregularity of the stress-strain curve after the previous maximum stress attained. Numerical models for the sandstone and granite were developed based on the contact bond model in PFC2D. Fractal dimension method was employed to detect the DME for two types of the rock. The results demonstrate that the fractal dimension method is effective and reliable in the identification of DME in rock.