| Can you clarify in what way you understand that documents are not removed from the memory?
1. After solution run (two projects:asp.net, silverlight app) Instance of IE 9 at task manager shows 60-62 mb of memory usage.
2. When I download a first pdf from a server side to telerik pdf control, the memory usage increase to nearly 70-75 mb ( exact size of upload file - 1 mb).
3. When I download another pdf file from server, the memory usage increases up to 200 mb. (though pdf file size is about 2 mb). (It`s consist of images inserted inside a pdf file)
I`ve attached 3 pics which show memory usage.
1. 0 pdf files download from server
2. 1 pdf files download from server
3. 2 pdf files download from server
The code of server side which sends file in chunks by bytes. (Code of client side I published in my first post. )
using
System;
using
System.IO;
using
System.Linq;
namespace
ATZO.Web.Files
{
public
partial
class
FileView : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
var doc = Page.Request.QueryString[
"docId"
];
// some check logic
if
(doc ==
null
)
{
}
var DocumentId=
long
.Parse(doc);
Response.ContentType =
"application/pdf"
;
Response.AddHeader(
"Pragma"
,
"no-cache"
);
var doc =
new
document();
//get document from database
using
(var dbConnect=
new
DBConnect())
{
doc= dbConnect.reg_document.SingleOrDefault(_=> _.DocId == DocumentId);
}
int
BufferSize = 8000;
var fileBytes = doc.fileDATA;
try
{
long
fileSize = fileBytes.Length;
int
chunkLength = 0;
int
position = 0;
var chunk =
new
Byte[BufferSize];
//count of bytes left to transmit
var bytesLeftToTransmit = fileSize;
while
(bytesLeftToTransmit > 0)
{
chunkLength = fileBytes.Skip(position).Take(BufferSize).Count();
chunk = fileBytes.Skip(position).Take(chunkLength).ToArray();
Response.OutputStream.Write(chunk, 0, chunkLength);
Response.Flush();
position += chunkLength;
bytesLeftToTransmit -= chunkLength;
}
}
finally
{
Response.End();
}
Response.End();
}
}
}