More and more smart mobile devices with storing and processing capabilities have been designed to adapt to the development of wireless mobile networks. Different from data processing by network center node previously, edge devices can also process initial data to produce effective information, which yields new security requirements and challenges. The current confidentiality protection methods which consume excessive memory space and reduce the system performance sharply are not applicable for this kind of devices which have limited resources and power dissipation. This paper presents a memory confidentiality protection method based on optimized dynamic keys and compression counters, which makes improvements from two aspects: the algorithm structure and counter overflow update algorithm. The design of dynamic mapping table and partition of counter area reduce the on-chip memory occupation. The optimized update algorithm reduces the amount of calculations when the counter overflows. The proposed method is compared with the split counter and block encryption mode. The experiment results show that the resource occupation is less and the average reduction rate of 11.84% is significantly better in the aspect of system performance.