Fixed memory locking twice