VB.NET Memory Management

Update: I may confuse memory usage issues with UI sharing the same thread and processing (as pointed out by MusiGenesis below). But regarding memory usage, I still can’t find VB .net specific syntax, although people have pointed out some great .Net and C# information below (if I am more proficient in these technologies, I can adapt to the work of VB.net).

I am creating a VB.Net application.

>The application basically parses data
files located on the client computer
to DataSet/DataTables.
>and then use
DataView, it breaks
DataTables become manageable blocks,
write XML and send XML data to
web service.

The general concept works fine, but I The problem encountered is that when the program is used to load more and more files, the Mem Usage on the task manager keeps growing.

At startup, before doing anything, the VB application has 27,000 K.
Once the file is parsed, even after I process the File handle, the data increases a lot. I deleted everything in the code and it seems that the memory in Mem Usage is still captured. For why Mem Usage is growing There is no rhyme or reason (i.e. sometimes it can grow 20mb when reading a 7mb file, but sometimes it does not increase at all when reading a 3mb file). Sometimes, it releases some memory when the parsing is complete, and other times it just keeps .

I have seen .Net Memory Profiler and did not really do this.
I have read a lot about .Net memory management on the Internet, about Dispose and “Nothing” and DataSet Wait, but I haven’t really found anything about VB.Net.

My general question is: Are there any good tutorials/books/blogs/etc. showing about managing VB.Net applications More in-depth tutorials on the memory (i.e. how/when to dispose/close, etc.), or does anyone have some specific tips from experience there.

< /div>

First, you need to be aware that Task Manager is showing you the amount of memory that the operating system has allocated to your application. This is not necessarily the amount of memory actually used. When .NET When the application is started for the first time, the operating system allocates memory for it, just like any process. Then, .NET runs Time to further divide the memory and manage its use. Runtime can be considered “greedy”, because once the operating system allocates memory, unless the operating system specifically requires it, it will not return it. The result is in the task manager The memory usage is not accurate.

To accurately understand the memory usage, you need to use the performance monitor and add the appropriate counters.

As for IDisposable and dispose modes, you may You won’t find a lot of language-specific terms to discuss it, because it is provided by the .NET Framework itself and has nothing to do with the language. No matter what language you use, the pattern is the same, only the syntax is different.

< p>There are several reference materials that can provide you with information about how memory management works. I have two blog posts, one about Using Garbage Collection in .NET, and the other listing two things I have created in .NET. A presentation on memory management of various resources.

The best “rule of thumb” is that if a class implements IDisposable, it will do so for some reason, and you should make sure that you are done Call Dispose() when using an instance. Using the using statement is the easiest to implement.

Update: I may share the same memory usage problem with the UI Threading is confused with processing (as pointed out by MusiGenesis below). But regarding memory usage. I still can’t find VB.net specific syntax, although people have pointed out some great .Net and C# information below (if I am more proficient in these technologies, so I can adapt to the work of VB.net).

I am creating a VB.Net application.

>The application is basically Parse data
file located on client computer
to DataSet/DataTables.
>and then use
DataView, it breaks
DataTables become manageable block,
write XML And send the XML data to the
web service.

The general concept works fine, but the problem I have is that when the program is used to load more and more files, the Mem Usage keeps growing.

At startup, before doing anything, the VB application has 27,000 K.
Once the file is parsed, even after I process the File handle, the data will increase a lot I deleted everything in the code and it seems that the memory in Mem Usage is still captured. There is no rhyme or reason for why Mem Usage is growing (i.e. sometimes It can grow 20mb when reading a 7mb file, but sometimes it does not increase at all when reading a 3mb file). Sometimes, it releases some memory when the parsing is complete, and other times it just keeps it.

I have seen .Net Memory Profiler and did not really do this.
I have read a lot about .Net memory management on the Internet, about Dispose and “Nothing” and DataSet, etc., but did not really find Anything about VB.Net.

My general question is: Are there any good tutorials/books/blogs/etc. showing more in-depth tutorials on managing memory in VB.Net applications ( I.e. how/when to dispose of/close, etc.), or does anyone have some specific tips from there.

First, you need to be aware of the task manager It is showing you the amount of memory that the operating system has allocated to your application. This is not necessarily the amount of memory actually used. When a .NET application is first launched, the operating system allocates memory for it, just like for any process Then, the .NET runtime further divides this memory and manages how it is used. The runtime can be considered “greedy” because once the operating system allocates memory, it will not return it unless it is specifically required by the operating system. The result is inaccurate memory usage in Task Manager.

To accurately understand memory usage, you need to use Performance Monitor and add appropriate counters.

As for IDisposable And dispose mode, you may not find a lot of language-specific terms to discuss it, because it is provided by the .NET Framework itself and has nothing to do with the language. No matter what language you use, the mode is the same, only the syntax is different .

There are several reference materials that can provide you with information about how memory management works. I have two blog posts, one about Using Garbage Collection in .NET, and the other listing what I used to Create two presentations about memory management in various resources in .NET.

The best “rule of thumb” is that if a class implements IDisposable, it will do so for some reason , You should make sure to call Dispose() when you are finished using the instance. It is easiest to use the using statement.

Leave a Comment

Your email address will not be published.