相关疑难解决方法(0)

如何创建(32位).NET应用程序以使用3 GB RAM?

我正在创建一个需要使用大量RAM的.NET应用程序(C#).我最近知道在32位版本的Windows XP上我只能使用2 GB,除非我使用/3Gb交换机,并IMAGE_FILE_LARGE_ADDRESS_AWARE在可执行标头中设置标志.但是因为我正在开发.NET应用程序,我想我无法直接修改可执行文件,是吗?那么,我该怎么做才能让我的应用程序使用3 GB?

.net memory windows

12
推荐指数
2
解决办法
9305
查看次数

GZIP解压缩C#OutOfMemory

我有很多大的gzip文件(大约10MB - 200MB),我从ftp下载解压缩.

所以我试着google并找到一些gzip解压缩的解决方案.

    static byte[] Decompress(byte[] gzip)
    {
        using (GZipStream stream = new GZipStream(new MemoryStream(gzip), CompressionMode.Decompress))
        {
            const int size = 4096;
            byte[] buffer = new byte[size];
            using (MemoryStream memory = new MemoryStream())
            {
                int count = 0;
                do
                {
                    count = stream.Read(buffer, 0, size);
                    if (count > 0)
                    {
                        memory.Write(buffer, 0, count);
                    }
                }
                while (count > 0);
                return memory.ToArray();
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

它适用于50mb以下的任何文件但是一旦我输入超过50mb我得到系统内存异常.异常之前的最后位置和内存长度是134217728.我不认为它与我的物理内存有关系,我知道我使用32位时不能有超过2GB的对象.

我还需要在解压缩文件后处理数据.我不确定内存流是否是最好的方法,但我不喜欢写入文件,然后再次读取文件.

我的问题

  • 为什么我得到System.OutMemoryException?
  • 什么是解压缩gzip文件并在之后进行一些文本处理的最佳解决方案?

c# compression gzip out-of-memory gzipstream

6
推荐指数
1
解决办法
4559
查看次数

小应用程序的高内存使用率

我只是构建一个非常简单的基于事件的代理监视器顶部禁用代理设置取决于网络位置是否可用.

问题是该应用程序是一个小的10KB,并具有最小的接口,但它使用10MB的内存.

代码非常简单:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.NetworkInformation;
using Microsoft.Win32;

namespace WCSProxyMonitor
{
    class _Application : ApplicationContext
    {
        private NotifyIcon NotificationIcon = new NotifyIcon();
        private string IPAdressToCheck = "10.222.62.5";

        public _Application(string[] args)
        {
            if (args.Length > 0) 
            {
                try
                {
                    IPAddress.Parse(args[0]); //?FormatException
                    this.IPAdressToCheck = args[0];
                }
                catch (Exception) 
                {}
            }

            this.enableGUIAspects();
            this.buildNotificationContextmenu();
            this.startListening();
        }

        private void startListening() 
        {
            NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(networkChangeListener);
        }

        public void networkChangeListener(object sender, EventArgs e)
        {
            //foreach …
Run Code Online (Sandbox Code Playgroud)

c# memory-management

3
推荐指数
1
解决办法
3544
查看次数