Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a variable in c#
Now I want to clear all those variable from computer memory.

There is a exe called Dumpit.exe, It is used to retrieve data from computer memory when I use Dumpit it retrieve all my data from my computer memory.
Now I want to secure my data so I want to delete my data from computer memory permanently.

Is there any way to do that?

What I have tried:

I tried garbage collector but that too also not working
Posted
Updated 8-Jul-19 3:34am
v2
Comments
Patrice T 4-Jul-19 8:24am    
What is the concern?
AkashDaniel 5-Jul-19 2:34am    
To secure the data
There is a application called Dumpit.exe,It is used to retrieve memory dump.It retrieved all my data stored in computer memory.so i want to delete the data permanently from computer memory in order to make my data secure.
Patrice T 5-Jul-19 3:07am    
Use Improve question to update your question.
So that everyone can pay attention to this information.
AkashDaniel 5-Jul-19 3:15am    
Ok Now I edited my question

That's complicated, in many cases very complicated, or even near impossible.

The first problem is that not all variables can be changed. Strings for example are immutable: they cannot be changed once created. When you try to modify a string:
C#
string s = "hello";
s = s + " world!";
A new string long enough for the revised version is created, and the original data is copied, then the new segment is appended to that. The original string content is not changed in any way (and unless you have kept a second reference to it) cannot even be accessed again.

So within C#, there are variables you cannot change or remove, and that means you cannot "clear all those variable from computer memory". Even if you did get the Garbage collector to dispose of them, that does not remove the content from memory, it just marks the space as "available" and when that specific piece of memory is reused the value will be at least partially overwritten. And you have no control over that at all: the memory allocator will use memory as seems appropriate to it at the time, you can;t force it to use any free segment.

And it gets worse, because Windows (like most modern OSes) uses virtual memory, which means that if it starts to "run short" of real physical memory, it "pages" some of it to disk to free it up, which means that at any point during execution your whole app memory may be written to disk and "pulled back" when your app needs it. And that you have absolutely no control over, you don't even know it is happening!

So you can't do it, you can't control it, and you may find it "just sitting there" on your hard drive a month later! (Worse, it's often possible to recover the last 5 or 6 data sets written to a magnetic media even after they have been overwritten!)
 
Share this answer
 
v2
Comments
BillWoodruff 5-Jul-19 2:09am    
+5 very useful explanation of why our sins are never forgiven :)
AkashDaniel 5-Jul-19 2:30am    
HAHAHA
Securing data and deallocating from RAM are totally different things. I think you want't to use your data while your application is running - so it's memory will always be in RAM (or even on the harddisk through paging). You can use encryption and SecureStrings to secure/obscure your data.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900