It's not a brilliant solution for your problem, but it could help you a bit.
In a TCL while loop you can do this two command:
while ... {
run 100 ns;
mem save -outfile $filename...
}
Note that a Modelsim DO file is a TCL file.
A better solution would be to add the dump of the memory in the 'onbreak' function.
onbreak {mem save ...}
Whenever you break or stop the simulation, the content of the RAM will be saved. Then you still need a trigger to break the simulation. Somebody?