You can't. Because the memory of B at this time is random. It could be:
- still untouched and look exactly like before
- something new, that either gives unexpected results, or crashes
- inaccessible
If you have code (a bigger project) that has this issue:
1) You can use -gh and set the environment "keepreleased"
2) On Linux: use valgrind --tool=memcheck.
valgrind will tell you when, where, .... all of it.