Click here to Skip to main content
14,325,178 members
   

C#

 
GeneralRe: How instantly free up the memory for List<T> & DataSet Pin
josda100011-Apr-19 15:38
memberjosda100011-Apr-19 15:38 
AnswerRe: How instantly free up the memory for List<T> & DataSet Pin
OriginalGriff11-Apr-19 20:11
protectorOriginalGriff11-Apr-19 20:11 
GeneralRe: How instantly free up the memory for List<T> & DataSet Pin
Mou_kol14-Apr-19 1:33
memberMou_kol14-Apr-19 1:33 
GeneralRe: How instantly free up the memory for List<T> & DataSet Pin
OriginalGriff14-Apr-19 1:41
protectorOriginalGriff14-Apr-19 1:41 
AnswerRe: How instantly free up the memory for List<T> & DataSet Pin
#realJSOP12-Apr-19 3:16
mve#realJSOP12-Apr-19 3:16 
GeneralRe: How instantly free up the memory for List<T> & DataSet Pin
Mou_kol14-Apr-19 1:36
memberMou_kol14-Apr-19 1:36 
GeneralRe: How instantly free up the memory for List<T> & DataSet Pin
#realJSOP16-Apr-19 1:40
mve#realJSOP16-Apr-19 1:40 
AnswerRe: How instantly free up the memory for List<T> & DataSet Pin
jschell13-Apr-19 6:35
memberjschell13-Apr-19 6:35 
It is important to understand the difference between memory that is being used and memory that at one time was used. The first cannot be freed by any means. You must stop using it and when you do then it moves into the second category where it might be freed.


If your allocations are below 85,000 bytes then any allocation request will do a garbage collection itself if there is not enough free memory to meet the needs of the request. This will happen (basically) up until you run out of memory because you are 'using' all of it. It will not free memory if you are using(pointing) to it.


If the allocated size is larger than 85,000 bytes (bytes, not chars, ints, etc) then the memory handling is slightly different in that between allocating and free allocations, if those are not somewhat sequential one can end up with having enough free memory but not actually succeeding in getting it because the memory is fragmented. For more on that you must learn quite a bit about how "heaps" in general work (not just C#) and how those can become fragmented. Once you understand that then you can look at the C# "Large Object Heap".

Your loop has 1,000,000 items and for a 64 bit machine you would need to have an item in every member of that list and each item would need to be about 10,000 bytes in size before I would suspect it to be a problem.

Mou_kol wrote:
button2_Click


Regardless of the above however that method suggests a UI. And a UI list with a million items in it is a BAD design.

Any UI with a list that attempts to contain more than 1000 items EVER, is a BAD design. And that might even be high.

Learn how to do paging instead. Also learn how to provide a method that allows the user to provide criteria and search for what they want in the list.
AnswerRe: How instantly free up the memory for List<T> & DataSet Pin
Dave Kreskowiak14-Apr-19 4:48
mveDave Kreskowiak14-Apr-19 4:48 
QuestionWhat List TrimExcess() does and when to use it Pin
Mou_kol11-Apr-19 9:40
memberMou_kol11-Apr-19 9:40 
AnswerRe: What List TrimExcess() does and when to use it Pin
Mycroft Holmes11-Apr-19 12:00
memberMycroft Holmes11-Apr-19 12:00 
QuestionHow do I apply the Settings.settings values at design time? Pin
Ayub Kokabi11-Apr-19 0:38
memberAyub Kokabi11-Apr-19 0:38 
AnswerRe: How do I apply the Settings.settings values at design time? Pin
Ralf Meier11-Apr-19 1:02
professionalRalf Meier11-Apr-19 1:02 
GeneralRe: How do I apply the Settings.settings values at design time? Pin
Ayub Kokabi11-Apr-19 1:48
memberAyub Kokabi11-Apr-19 1:48 
AnswerRe: How do I apply the Settings.settings values at design time? Pin
OriginalGriff11-Apr-19 2:28
protectorOriginalGriff11-Apr-19 2:28 
GeneralRe: How do I apply the Settings.settings values at design time? Pin
Ayub Kokabi11-Apr-19 3:22
memberAyub Kokabi11-Apr-19 3:22 
Questionnon intersecting circles Pin
Member 1422403810-Apr-19 3:54
memberMember 1422403810-Apr-19 3:54 
AnswerRe: non intersecting circles Pin
OriginalGriff10-Apr-19 3:55
protectorOriginalGriff10-Apr-19 3:55 
AnswerRe: non intersecting circles Pin
Dave Kreskowiak10-Apr-19 5:16
mveDave Kreskowiak10-Apr-19 5:16 
AnswerRe: non intersecting circles Pin
Gerry Schmitz10-Apr-19 6:46
mveGerry Schmitz10-Apr-19 6:46 
AnswerRe: non intersecting circles Pin
Luc Pattyn10-Apr-19 9:58
professionalLuc Pattyn10-Apr-19 9:58 
Questioncan't catch task exception with C# Pin
Member 142229339-Apr-19 16:08
memberMember 142229339-Apr-19 16:08 
AnswerRe: can't catch task exception with C# Pin
Member 142229339-Apr-19 18:07
memberMember 142229339-Apr-19 18:07 
AnswerRe: can't catch task exception with C# Pin
OriginalGriff9-Apr-19 20:05
protectorOriginalGriff9-Apr-19 20:05 
AnswerRe: can't catch task exception with C# Pin
Nathan Minier10-Apr-19 2:13
professionalNathan Minier10-Apr-19 2:13 

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.