Windows应用商店应用 - OutOfMemoryException [英] Windows store app - OutOfMemoryException

查看:111
本文介绍了Windows应用商店应用 - OutOfMemoryException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在运行时期间不断出现内存不足异常

My app keeps getting an out of memory exception during runtime, at this code

    public  async void Read()
        {
            //============ CREATE OBJECTS ====================
            object outValue;
            StreamSocket socket;        
            CoreApplication.Properties.TryGetValue("clientSocket", out outValue);
            socket = (StreamSocket)outValue;
            DataReader Reader = new DataReader(socket.InputStream);
           // Reader.InputStreamOptions = InputStreamOptions.Partial;
         
          
            var charBuffer = new List<int>();
          
            //=================================================
            var stringHeader = await Reader.LoadAsync(4);
            if (stringHeader == 0)
            {
               //DISCONNECTED
                return;
            }
            int strLength = Reader.ReadInt32();
            uint numStrBytes = await Reader.LoadAsync((uint)strLength);
            string msg = Reader.ReadString(numStrBytes);
            OnDataRecieved(msg);
            Read();
        }

更具体地说,这部分: 

More specifically at this part: 

 uint numStrBytes = await Reader.LoadAsync((uint)strLength);

可能出错?

推荐答案

您是否尝试调试代码并检查Reader.ReadInt32()返回的值是什么?
Have you try to debug the code and check what is the value return by Reader.ReadInt32() ?


这篇关于Windows应用商店应用 - OutOfMemoryException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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