Hello,
I am the sample FPSEPublish
(http://blog.baeke.info/blog/_archive.../3/393158.html) code to upload a
document to Sharepoint (WSS). This works perfectly for samll documents.
Problem:
When I attempt to upload a huge document (300Megabayte) on a PC with 3.6Gig
RAM I am getting a OutOfMemoryExce ption when the program attempts to read the
file into a MemoryStream.
The problem has nothing to do with Sharepoint as it is happening prior to
the FP RPC upload atempt.
Questions: Is there a limit on the amount of memory that is assigned to the
GarbageCollecte d heap that is being reached? Using the Sysinternals
ProcessExplorer program I can see the amount of memory being consumed by the
process as follows:
Total Reserved Bytes: 897,544,192
I have tried to understand how the CLR is allocating memory to no avail.
Any help/pointer is greatly appreciated
Sample Code:
+++++++++++++++ +++++++++++++++ +++++
public void PutDocument(str ing uri, string fileName, string metaInfo)
{
//GC.Collect();
//GC.WaitForPendi ngFinalizers();
//GC.Collect();
Uri myUri = new Uri(uri);
string webUrl, fileUrl;
UrlToWebUrl(uri , out webUrl, out fileUrl);
if (null == metaInfo)
metaInfo = "";
if (!File.Exists(f ileName))
throw new Exception("Coul d not find file" + fileName);
string postBody = String.Format(
"method=put+doc ument&service_n ame=&document=[document_name={ 0};meta_info=[{1}]]&put_option=ove rwrite&comment= &keep_checked_o ut=false\n",
HttpUtility.Url Encode(fileUrl) ,
metaInfo);
ASCIIEncoding encoding = new ASCIIEncoding() ;
MemoryStream stream = new MemoryStream();
stream.Write(en coding.GetBytes (postBody), 0, postBody.Length );
FileStream fs = File.OpenRead(f ileName);
byte[] b = new byte[4096];
while (fs.Read(b, 0, b.Length) > 0)
{
//GC.Collect();
//GC.WaitForPendi ngFinalizers();
//GC.Collect();
try
{
stream.Write(b, 0, b.Length); //FAILS TO WRITE TO STREAM AFTER STREAM
SIZE REACHES APPROX 270Meg
//System.Diagnost ics.Debug.Write Line(stream.Len gth.ToString()) ;
}
catch(Exception ex)
{
System.Diagnost ics.Trace.Write Line(ex.Message );
}
}
fs.Close();
SendRequest(myU ri.GetLeftPart( UriPartial.Auth ority) + webUrl +
"/_vti_bin/_vti_aut/author.dll", stream.GetBuffe r(), stream.Length);
stream.Close();
}
+++++++++++++++ +++++++++++++++ +++++