I don't believe in any solution to this problem and won't attempt it. Don't bother trying. In fact, see
's comments. In theory this is something you can do in C but some discussions on sec-prog lead me to think that it may be difficult to impossible to reliably remove something from memory because the compiler is handy at optimizing away these "useless" optimizations. I recall both MSVC and gcc were under discussion.