【问题标题】:OutOfMemoryException during remote method call远程方法调用期间出现 OutOfMemoryException
【发布时间】:2010-01-28 05:28:59
【问题描述】:

我在进行远程方法调用时遇到 OutOfMemoryException。

"RemoteEntity.SetLocalStore(DATASET);"

传递的值是数据集。

注意数据集大小为 38mb

环境c#VS2008

谢谢

代码:

private void backgroundSync_DoWork(object sender, DoWorkEventArgs e)
        {            
            backgroundSync.ReportProgress(10, "Fetching data for sync ...");
            EngagementSet _remoteSet = HKMPClient.Instance.RemoteEntity.GetLocalStore();



            //Update to release memory.
            HKMPClient.Instance.RemoteEntity.SetLocalStore(null);
            //dispose RemoteEntity
            HKMPClient.Instance.DisconnectAndDispose();

            HKMP.EngagementWorks.Windows.BLL.Engagements.Engagement.MergeEntitiesInLimitedConnecitivity(_remoteSet,EngagementID);            
            backgroundSync.ReportProgress(10, "Synchronizing Engagement ...");
            DialogSync _dlgSync = new DialogSync(this.EngagementID, _remoteSet);
            _dlgSync.ServiceRequestStarted += new DialogSync.OnServiceRequestStarted(_dlgSync_ServiceRequestStarted);
            _dlgSync.ServiceRequestCompleted += new DialogSync.OnServiceRequestCompleted(_dlgSync_ServiceRequestCompleted);
            if (_dlgSync.IsShown())
            {
                _dlgSync.StartPosition = FormStartPosition.CenterParent;
                _dlgSync.WindowState = FormWindowState.Normal;
                _dlgSync.ShowDialog();
            }
            //Disposed to release object.
            _dlgSync.Dispose();
            _dlgSync = null;


            // connect again                
            HKMPClient.Instance.Connect(e.Argument.ToString());

            _remoteSet.RemotingFormat = SerializationFormat.Binary;

            HKMPClient.Instance.RemoteEntity.SetLocalStore(_remoteSet);

        }

【问题讨论】:

  • 我在这里的一些代码中得到了NullReferenceException,你能帮帮我吗?
  • 出于兴趣,您的客户端线程是如何运行的?

标签: c# remoting out-of-memory


【解决方案1】:

我想你知道答案了,38mb 对于远程调用来说太大了。通过将您的问题简化为仅在本地运行的两个函数来显示一个完整的示例将有助于进一步诊断它。

这将有助于检测它是数据集的大小还是远程接口/网络配置中的大小限制。

另外,拥有一个工作示例将允许其他人复制问题并查看类型信息(例如,我们看不到引发异常的对象类型,也无法在 MSDN 中查找任何约束)。我敢肯定,有了这个,有人将能够提供一个明确的答案。

将代码简化为示例的行为本身可能会让您找到原因。

瑞恩

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-30
    • 1970-01-01
    • 1970-01-01
    • 2023-04-11
    • 2012-03-31
    • 2012-04-09
    • 1970-01-01
    相关资源
    最近更新 更多