Irretrievably destroying data in Java

后端 未结 10 1430
时光说笑
时光说笑 2020-12-10 04:26

Is there anyway in Java to delete data (e.g., a variable value, object) and be sure it can\'t be recovered from memory? Does assigning null to a variable in Jav

10条回答
  •  不思量自难忘°
    2020-12-10 04:59

    Due to the wonders virtual memory, it is nearly impossible to delete something from memory in a completely irretrievable manner. Your best bet is to zero out the value fields; however:

    • This does not mean that an old (unzeroed) copy of the object won't be left on an unused swap page, which could persist across reboots.
    • Neither does it stop someone from attaching a debugger to your application and poking around before the object gets zeroed or crashing the VM and poking around in the heap dump.

提交回复
热议问题