G
Guest
Hello,
I am the sample FPSEPublish
(http://blog.baeke.info/blog/_archives/2005/3/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 OutOfMemoryException 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
GarbageCollected 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(string uri, string fileName, string metaInfo)
{
//GC.Collect();
//GC.WaitForPendingFinalizers();
//GC.Collect();
Uri myUri = new Uri(uri);
string webUrl, fileUrl;
UrlToWebUrl(uri, out webUrl, out fileUrl);
if (null == metaInfo)
metaInfo = "";
if (!File.Exists(fileName))
throw new Exception("Could not find file" + fileName);
string postBody = String.Format
"method=put+document&service_name=&document=[document_name={0};meta_info=[{1}]]&put_option=overwrite&comment=&keep_checked_out=false\n",
HttpUtility.UrlEncode(fileUrl),
metaInfo);
ASCIIEncoding encoding = new ASCIIEncoding();
MemoryStream stream = new MemoryStream();
stream.Write(encoding.GetBytes(postBody), 0, postBody.Length);
FileStream fs = File.OpenRead(fileName);
byte[] b = new byte[4096];
while (fs.Read(b, 0, b.Length) > 0)
{
//GC.Collect();
//GC.WaitForPendingFinalizers();
//GC.Collect();
try
{
stream.Write(b, 0, b.Length); //FAILS TO WRITE TO STREAM AFTER STREAM
SIZE REACHES APPROX 270Meg
//System.Diagnostics.Debug.WriteLine(stream.Length.ToString());
}
catch(Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.Message);
}
}
fs.Close();
SendRequest(myUri.GetLeftPart(UriPartial.Authority) + webUrl +
"/_vti_bin/_vti_aut/author.dll", stream.GetBuffer(), stream.Length);
stream.Close();
}
+++++++++++++++++++++++++++++++++++
I am the sample FPSEPublish
(http://blog.baeke.info/blog/_archives/2005/3/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 OutOfMemoryException 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
GarbageCollected 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(string uri, string fileName, string metaInfo)
{
//GC.Collect();
//GC.WaitForPendingFinalizers();
//GC.Collect();
Uri myUri = new Uri(uri);
string webUrl, fileUrl;
UrlToWebUrl(uri, out webUrl, out fileUrl);
if (null == metaInfo)
metaInfo = "";
if (!File.Exists(fileName))
throw new Exception("Could not find file" + fileName);
string postBody = String.Format
"method=put+document&service_name=&document=[document_name={0};meta_info=[{1}]]&put_option=overwrite&comment=&keep_checked_out=false\n",
HttpUtility.UrlEncode(fileUrl),
metaInfo);
ASCIIEncoding encoding = new ASCIIEncoding();
MemoryStream stream = new MemoryStream();
stream.Write(encoding.GetBytes(postBody), 0, postBody.Length);
FileStream fs = File.OpenRead(fileName);
byte[] b = new byte[4096];
while (fs.Read(b, 0, b.Length) > 0)
{
//GC.Collect();
//GC.WaitForPendingFinalizers();
//GC.Collect();
try
{
stream.Write(b, 0, b.Length); //FAILS TO WRITE TO STREAM AFTER STREAM
SIZE REACHES APPROX 270Meg
//System.Diagnostics.Debug.WriteLine(stream.Length.ToString());
}
catch(Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.Message);
}
}
fs.Close();
SendRequest(myUri.GetLeftPart(UriPartial.Authority) + webUrl +
"/_vti_bin/_vti_aut/author.dll", stream.GetBuffer(), stream.Length);
stream.Close();
}
+++++++++++++++++++++++++++++++++++