Ari said:
Hey,
I was wondering, is there a way to clear the RAM Ruby uses in some
code? For instance, if I read in an entire file into the memory, can I
clear the RAM that was used?
I guess that would probably be quite difficult because the language
doesn't guarantee anything regarding where the memory is allocated, when
it is freed, overwritten or reallocated. You may want to implement this
in something closer to the metal like C where you get this kind of control.
If you really must use Ruby I suppose that if you pay attention to the
objects you use to store the data from the file and find out how they
use memory (by looking at the actual Ruby C source code mainly) then you
could probably read the file, track all objects passed information you
want to protect and define methods that you know (from actual C source
reading) will overwrite any important information left around. You'll
have to make sure your code runs on the exact smae version of the
interpreter and libs you used when examining the sources. Messy...
A simpler way (but maybe not workable for you) would be to fork to
handle the file processing and run the whole code on an OS which
scrambles memory of terminated processes (I'm not sure, but hardened
versions of Linux might very well implement this).
Lionel.