我有Web站点和Monotouch应用程序托管的WCF服务,它可以显示和更新服务中的PDF文档。 PDF文件大小可以从1字节到20 Mb。 当我有少量文档(少于100个,文档总大小为30Mb)时,更新过程会成功完成。但是,当我有很多文件(超过300个,文件大小通常为100Mb)时,我的程序在iPad 1上终止,但在iPad 2上仍然有效。我想在的问题。当iOS使用很多内存时,iOS会杀死我的应用。但我不知道问题出在哪里,也许Monotouch GC不会从fileData字节数组中清除内存?在iPad上Monotouch和WCF,内存使用情况
方法,更新文件:
protected bool BeginUpdateProcess()
{
try {
var binding = new BasicHttpBinding();
binding.MaxBufferSize = 52428800;
binding.MaxBufferPoolSize = binding.MaxReceivedMessageSize = 52428800L;
binding.ReaderQuotas.MaxStringContentLength = binding.ReaderQuotas.MaxArrayLength = 52428800;
var endpoint = new EndpointAddress(string.Format("http://{0}/Services/UpdateDataService.svc", UpdateInfo.Instance.ServerIP));
using (var dataService = new UpdateDataServiceClient(binding, endpoint)) {
// Get document list for update
int[] docIds;
try {
docIds = dataService.GetModifiedDocumentIds(mLastUpdated);
} catch (Exception ex) {
LogWriter.Instance.WriteToLog("UpdateFromServiceEror: Can't load modified document ids list", ex);
return false;
}
// Get each document content and save it to iPad
for (int i = 0; i < docIds.Length; i++) {
if (Canceled) {
return true;
}
try {
byte[] fileData = dataService.GetDocumentTransData(docIds[i]);
SaveDocument(fileData);
} catch (Exception ex) {
LogWriter.Instance.WriteToLog(string.Format("Can't load or save file, id={0}", docIds[i]), ex);
return false;
}
}
dataService.Close();
}
} catch (Exception ex) {
LogWriter.Instance.WriteToLog("Error when update from service", ex);
}
}
的网站WCF设置:
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="Transport"
closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="52428800" maxBufferPoolSize="524288" maxReceivedMessageSize="52428800"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="64"
maxStringContentLength="52428800"
maxArrayLength="52428800"
maxBytesPerRead="16384"
maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="iDict.Site.Services.UpdateDataService" behaviorConfiguration="Default">
<host>
<baseAddresses>
<add baseAddress="http://localhost:57709/Services/UpdateDataService.svc"/>
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="Transport" contract="iDict.Site.Services.IUpdateDataService" />
</service>
</services>
我不确定你的意思是**常见大小**?它看起来像**总**尺寸,例如*当我的文件很少(低于100,文件的普通尺寸是30Mb)时,*会变成“当我有**少数**文件时,**少于100,**总数**大小的文件是30MB ... – poupou 2012-02-03 18:19:34
是的,你是对的,我纠正了我的问题。 – alexmac 2012-02-03 19:02:03