积极答复者
不关闭DbDataReader,会不会资源泄漏或内存泄漏

问题
答案
-
GC会帮你善后。
不过建议还是主动关闭。好习惯是慢慢养成的~~
family as water- 已标记为答案 Ai-hua Qiu 2011年1月6日 8:28
-
你好,
补充一点,建议你先关闭SQL DataReader,然后再关闭SQLConnection,我们可以using 语句去自动关闭SQLConnection。
此外,如果发现内存泄漏,我们可以用GC.Collect 方法,强制对所有代码进行即时垃圾回收。
更多信息,请参阅:
GC.Collect 方法
谢谢,
邱爱华
Ai-hua Qiu[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已建议为答案 LiweiyinMicrosoft employee, Moderator 2010年12月31日 8:48
- 已标记为答案 Ai-hua Qiu 2011年1月6日 8:28
全部回复
-
GC会帮你善后。
不过建议还是主动关闭。好习惯是慢慢养成的~~
family as water- 已标记为答案 Ai-hua Qiu 2011年1月6日 8:28
-
你好,
补充一点,建议你先关闭SQL DataReader,然后再关闭SQLConnection,我们可以using 语句去自动关闭SQLConnection。
此外,如果发现内存泄漏,我们可以用GC.Collect 方法,强制对所有代码进行即时垃圾回收。
更多信息,请参阅:
GC.Collect 方法
谢谢,
邱爱华
Ai-hua Qiu[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已建议为答案 LiweiyinMicrosoft employee, Moderator 2010年12月31日 8:48
- 已标记为答案 Ai-hua Qiu 2011年1月6日 8:28