我如何从内存中擦除字符串变量值 [英] How do i wipe string variable value from memory

查看:83
本文介绍了我如何从内存中擦除字符串变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





谷歌搜索了很多,但无法找到合适的答案...

使用'指针'到'gc。收集'...



一旦不再使用字符串变量,擦除内存有多难?



我把虚拟值和程序结束的时间。但这是一个很好的&有效的做事方式?



我的尝试:



googled擦拭记忆&使用或不使用gc.collect

解决方案

基本上,你不能 - 字符串是不可变的,你不能以任何方式改变它们。

相反,请使用: SecureString类 [ ^ ] - 它远没有那么灵活,向用户展示其内容确实很痛苦,但是......


有用的信息:

覆盖敏感& quot;是否是良好的安全编程习惯?变量在删除之前? - 信息安全堆栈交换 [ ^ ]



这个:

变量地址 - 罗塞塔代码 [ ^ ]


引用:

如何从内存中擦除字符串变量值 VB具有自动内存管理功能。您可以认为内存/垃圾管理是自动为您完成的。你无事可做。

引用:

我把虚拟值和程序结束的时间。但这是一个很好的&有效的做法?

基本上,没有必要,没有必要,因为新的价值不会覆盖旧价值。



你有特殊的理由吗?想要这样做吗?

引用:

为什么我想要这个?保护数据不被内存读取...不允许的人/程序/病毒等...

在这种情况下,不要使用VB,使用允许您手动管理内存并在之前擦除数据的语言释放记忆。


Hi,

googled a lot but cant find a working answer...
from using 'pointers' to 'gc.collect'...

how hard can it be to wipe the memory once the string variable isn't used anymore?

for the time i put a dummy value and the end of the procedure. But is this a good & effective way of doing?

What I have tried:

googled on wiping memory & using or not using gc.collect

解决方案

Basically, you can't - strings are immutable, and you can't change them in any way.
Instead, use this: SecureString class[^] - it's nowhere near as flexible, and it's truly a pain to show its content to the user, but...


usefull information:
Would it be good secure programming practice to overwrite a "sensitive" variable before deleting it? - Information Security Stack Exchange[^]

and this:
Address of a variable - Rosetta Code[^]


Quote:

How do I wipe string variable value from memory

VB have automatic memory management. You can consider that the memory/garbage management is doing it for you automatically. You have nothing to do.

Quote:

for the time i put a dummy value and the end of the procedure. But is this a good & effective way of doing?

Basically, no need, not necessary, because the new value will not overwrite the old one.

Do you have a special reason to want to do this ?

Quote:

Why Ii want to this? To protect data from being read in memory by ... unallowed persons/programs/viruses etc...

In this case, don't use VB, use a language that allow you to manage memory manually and wipe data before releasing the memory.


这篇关于我如何从内存中擦除字符串变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆