如何在wpf中解决System.out内存异常问题 [英] How To Solve System.out of memory Exception in wpf

查看:442
本文介绍了如何在wpf中解决System.out内存异常问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友,



我将大xmlfile插入mysqldatabase.But得到错误System.out的内存Exception.how to solve.plz帮帮我。这是我的code.thanks

Hi Friends,

am inserting large xmlfile into mysqldatabase.But got error System.out of memory Exception.how to solve.plz help me.this is my code .thanks

using ( var stringWriter = new StringWriter ( ) )
    {
    using ( var xmlTextWriter = XmlWriter.Create ( stringWriter ) )
        {
        XmlDoc2.WriteTo ( xmlTextWriter );
        xmlTextWriter.Flush ( );
        stringWriter.GetStringBuilder ( ).ToString ( );
        string xmlstr = stringWriter.GetStringBuilder ( ).ToString ( );
        DateTime today = DateTime.Now;
        string strqry =
            "insert into xmlfile ( XMLFile, DateTime) " +
            "values ( @XMLFile, @DateTime )";
        MySqlCommand cmd = new MySqlCommand ( strqry, connection, trns );
        cmd.Parameters.AddWithValue ( "@XMLFile", xmlstr );
        cmd.Parameters.AddWithValue ( "@DateTime", today );
        cmd.ExecuteNonQuery ( );
        }
    }

推荐答案

您遇到的问题OutOfMemoryException意味着那里没有足够的内存(RAM空间),所以你可以考虑释放一些空间。



作为此问题的解决方案的一些选项包括您尝试重新启动计算机。这将刷新机器的内存,并允许您再次运行进程。如果您的内存大小很小(小于1 GB),这将很有用。您的流程可能会在处理过程中遇到麻烦,而您会得到不响应。那么这个选项会很好。



否则,如果您的RAM大小超过1 GB。然后解决方案是确保您没有很多启动应用程序在地下运行并导致您的系统有多个打嗝。这些启动应用程序和进程贯穿整个系统的生命周期(特别是Windows服务导致相同)。解决方案永远不会停止开发WPF应用程序,继续。做吧!解决方案是缩短地下应用程序,流程和服务。您的开发环境必须具有足够的资源才能用于完成流程。
The problem that you are facing "OutOfMemoryException" means that there is not enough memory (RAM space) left, so you might consider releasing some space.

A few options as a solution to this problem include that you try to restart your machine. This would refresh your machine's memory and would allow you to run processes again. This would be helpful, if your memory size is low (less than 1 GB). Your processes might go through a hiccup through processing and you get "Not responding" too much. Then this option would be good.

Otherwise, if your RAM size is more than 1 GB. Then the solution would be to make sure you are not having a lot of start up applications that run underground and cause your system to have multiple hiccups. These start up applications and processes run through out the life cycle of your system (notably the Windows services cause the same). The solution would never be to stop developing the WPF application, go on. Do it! The solution is to cut short the underground applications, processes and services. Your development environment must have enough resources which you want to use to complete a process.


这篇关于如何在wpf中解决System.out内存异常问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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