存储过程完成后清除内存 [英] Clear memory once Stored proc completes

查看:149
本文介绍了存储过程完成后清除内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我目前已经开发了一个系统,其中正在导入aprrox 130万条记录。



一旦导入文件然后更新文件更新的表,以便导入计算其他表的id和必要的表可以更新



我有设法让我的过程工作,虽然我的内存有问题,一旦过程完成它似乎没有释放使用的物理内存。



当进程运行它占用了大约40%的可用物理内存



我使用以下vb.net代码来调用我的存储过程



使用con作为新的sqlconnection(ConnString)

Con.open()

dim cmd as new sqlcommand

cmd =(execute proc1,con)

cmd.executenonQuery()

con.close()

结束使用



大约有5个存储过程使用它代码。



有没有办法可以在进程完成后释放内存?

Hi
I currently have developed a system of which aprrox 1.3million records are being imported.

Once the files are imported the table that the files are updated in are then updated so that the import mathches the id's of the other tables and the necesary tables can be updated

I have managed to get my process to work though i have been having an issue on my memory that once the process completes it doesnt seem to release the physical memory used.

when the process runs it takes up about 40% of physical memory available

I use the following vb.net code to call my stored procs

using con as new sqlconnection(ConnString)
Con.open()
dim cmd as new sqlcommand
cmd = ("execute proc1",con)
cmd.executenonQuery()
con.close()
end using

there are about 5 stored procs that use this code.

Is there a way that i could release the memory once the process completes?

推荐答案

如果您正在查看TaskManager以查看您的应用程序正在使用多少内存,那么它就在骗你。​​



TaskManager向您显示.NET CLR有多少内存保留您的应用程序,而不是它实际使用了多少。这是托管堆。如果Windows想要回忆内存,CLR很乐意从堆中释放它并返回它。它做得很好,所以没有什么可以调整。



如果你想看看它使用了多少,打开ProcMon并使用.NET内存计数器。



您的代码也可能泄漏资源。也许你没有在完成它们时处理对象?
If you're looking in TaskManager to see how much memory your app is using, it's lying to you.

TaskManager is showing you how much memory the .NET CLR has RESERVED for your application, not how much it's actually using. This is the "managed heap". If Windows wants the memory back, the CLR is happy to free whatever it can from the heap and return it. It does a good job at it to, so there's nothing to "tune".

If you want to see how much it's using, open ProcMon and use the .NET Memory counters.

It's also possible that your code is leaking resources. Perhaps you're not Disposing objects when you're done with them??


你应该检查你的存储过程。我猜你正在使用游标来浏览数据。如果是这样,您应该考虑清理存储过程中的变量。还要考虑不要一次运行所有记录,而是创建10000个记录的批次并对其进行处理。这应该减少内存使用量。你对sql server中的内存使用情况没有那么多的控制,所以尽量只处理少量的数据来保持低的数量。
You should check your stored procedures. I guess you are using cursors to walk through the data. If so, you should consider cleaning up the variables in the stored procedures. Also consider not running through all records at once, instead create batches of 10000 records and work on them. This should reduce memory usage. You have not that much control about the memory usage in sql server, so try to keep the amount low with working on only low numbers of data.


此举


这篇关于存储过程完成后清除内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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