Hi ,
I am assigning decrypted string to a variable of datatype string. For eg
Dim str as string
str=" "
str= decrypted string from a file "sample1.dat"
The file sample1.dat is about 700KB of size.When i assign decrypted string from files like sample2.dat , sample3.dat , sample4.dat of 700 KB one after another i am getting out of memory exception. So what is a proper way of assigning huge size string values to a string datatype and how to dispose allocated memory. I used GC.collect, but also i am getting out of memory exception.

how to assign huge decrypted string values to String datatype?
hrubesh
Hi Senthil,
I don't believe the assignment is what's causing the problem since this is just another reference to the same memory. I believe what's causing the problem would be where you actually allocate the object. Are you doing anything like appending strings using the + operator if so, I would recommend using the stringbuilder.append for such operations since otherwise you'll create a lot of garbage. Also, there are some known issues with us fragmenting virtual memory when appending huge chunks to a stringbuilder object. Make sure there any no active references to the object and then do a GC.Collect(), this should solve the problem.
A debugging tool that might help you in figuring out memory and other bottlenecks is released with V2 SP1 called the NETCF remote performance monitor. A good blog can be found at http://blogs.msdn.com/stevenpr/archive/2006/04/17/577636.aspx.
Thanks,
Sandy