Click here to Skip to main content
15,887,861 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionVB.Net Text Encoding Pin
Member 1061435020-Feb-14 23:00
Member 1061435020-Feb-14 23:00 
AnswerRe: VB.Net Text Encoding Pin
Richard MacCutchan21-Feb-14 0:36
mveRichard MacCutchan21-Feb-14 0:36 
AnswerRe: VB.Net Text Encoding Pin
Eddy Vluggen21-Feb-14 21:06
professionalEddy Vluggen21-Feb-14 21:06 
QuestionMemory utilization of MemoryStream Pin
elix54520-Feb-14 9:18
elix54520-Feb-14 9:18 
AnswerRe: Memory utilization of MemoryStream Pin
Pete O'Hanlon20-Feb-14 9:35
mvePete O'Hanlon20-Feb-14 9:35 
AnswerRe: Memory utilization of MemoryStream Pin
Dave Kreskowiak20-Feb-14 9:36
mveDave Kreskowiak20-Feb-14 9:36 
GeneralRe: Memory utilization of MemoryStream Pin
elix54520-Feb-14 10:08
elix54520-Feb-14 10:08 
GeneralRe: Memory utilization of MemoryStream Pin
Dave Kreskowiak20-Feb-14 13:11
mveDave Kreskowiak20-Feb-14 13:11 
No, it's not. What you're storing is irrelevant. If you keep exceeding the capacity of the MemoryStream, it will keep allocating new arrays, twice as large as the last, until it can't grow any more (2GB).

These are the sizes the MemoryStream went through after you created it and keep adding more and more data to it:
256
512
1024
2048
4096
8192
16384
32768
65536
131072
262144
524288
1048576
2097152
4194304
8388608
16777216
33554432
67108864
134217728
268435456
536870912
1073741824
2147483648

Oh, look at that. It managed to hit 2GB in size right after you added 1073741824 bytes of information to it. It's allocating bigger and bigger blocks of memory because it has no way of knowing how big to make the array to that it fits your data perfectly.

If you want to keep it from getting to 2GB of memory, allocate the MemoryStream with the expected size as a parameter, say 1.5GB:
Dim ms As New MemoryStream(1610612736)

Now, if you exceed that, the MemoryStream will try to reallocate itself using twice the size you initially specified and that will lead to an OutOfMemory exception.

You can NOT look in Task Manager to see how much memory your app is using. It's telling you how much memory the .NET CLR as RESERVED for your app. This will always be larger than what your app is actually using.

GeneralRe: Memory utilization of MemoryStream Pin
elix54520-Feb-14 14:25
elix54520-Feb-14 14:25 
AnswerRe: Memory utilization of MemoryStream Pin
JonB26-Feb-14 5:19
JonB26-Feb-14 5:19 
QuestionGantt Chart Pin
Member 1057034317-Feb-14 0:39
Member 1057034317-Feb-14 0:39 
QuestionASP.NET Membership Pin
Meetmca16-Feb-14 18:17
professionalMeetmca16-Feb-14 18:17 
AnswerRe: ASP.NET Membership Pin
Richard MacCutchan16-Feb-14 22:26
mveRichard MacCutchan16-Feb-14 22:26 
QuestionQuestion about VB and Databases Pin
CaseLost14-Feb-14 17:05
CaseLost14-Feb-14 17:05 
AnswerRe: Question about VB and Databases Pin
Eddy Vluggen15-Feb-14 23:33
professionalEddy Vluggen15-Feb-14 23:33 
Questionsql query syntax in .net Pin
Member 1050621512-Feb-14 3:52
Member 1050621512-Feb-14 3:52 
AnswerRe: sql query syntax in .net Pin
Dave Kreskowiak12-Feb-14 4:30
mveDave Kreskowiak12-Feb-14 4:30 
AnswerRe: sql query syntax in .net Pin
thatraja12-Feb-14 4:31
professionalthatraja12-Feb-14 4:31 
AnswerRe: sql query syntax in .net Pin
Richard Deeming12-Feb-14 5:22
mveRichard Deeming12-Feb-14 5:22 
AnswerRe: sql query syntax in .net Pin
Eddy Vluggen12-Feb-14 6:56
professionalEddy Vluggen12-Feb-14 6:56 
GeneralRe: sql query syntax in .net Pin
Member 1050621512-Feb-14 22:01
Member 1050621512-Feb-14 22:01 
AnswerRe: sql query syntax in .net Pin
Eddy Vluggen12-Feb-14 22:28
professionalEddy Vluggen12-Feb-14 22:28 
GeneralRe: sql query syntax in .net Pin
Member 1050621512-Feb-14 22:35
Member 1050621512-Feb-14 22:35 
GeneralRe: sql query syntax in .net Pin
Eddy Vluggen13-Feb-14 0:31
professionalEddy Vluggen13-Feb-14 0:31 
GeneralRe: sql query syntax in .net Pin
Member 1050621513-Feb-14 1:39
Member 1050621513-Feb-14 1:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.