我有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