VS 2008 - GC.Collect: Memory Vs Performance?

Jan 29, 2011

I have an application (i've been working on for a long time) that has many tabs and controls and quite a few components And a good deal of design code. And a list box that has around 100k items (i had to put a loader to pass the 3-4 seconds while its loading to prevent it from not-responding)I had a few Gc.collect calls in specific places (mostly after many items are added or removed). When my application loads, i call GC.collect only once at the end of the load. The program consumes around 35K memory by the time its loaded. However, i decided to mess around abit (don't worry i made backups)First i started putting gc.collect in some random places, and to my surprise the memory upon loading was observably decreasing. Then I went ahead and put a macro that puts GC.Collect before every End Sub, Exit Function, Exit Sub, and Return value, there is. Basically every block in my application had atleat one GC.Collect.
I fixed some 6 or 7 silly replace errors and compiled. When the program launched, the memory used at the end of launch was 21K!

At first glance that seemed great, but then i realized switching between tabs was VERY glitchy. and adding new lists took around 10x more time than usual (the loader stayed on for around 20 seconds!) And even though the memory looked good, the program was useless like this.Then i decided to mess around differently. I removed GC.Collect from the entire solution. It was no longer called even once.At first glance, when i launched the app it consumed just under 60K memory. That seemed terrible. However i realized something: even though my program in that state showed on taskmanager that it was consuming alot more memory than usual, it seemed like it was lighter than ever! Switching tabs was faster than before, especially every time i go to the tab that has the listbox control with 100k items. Loading items took around 3-4 seconds, but there was no stutter when the list finished loading whereas before it had an evident 0.3s stutter after the items were added.

This was all surprising to me because i thought GC.Collect was first of all, something that it doesnt matter where or how many times you call it. I thought it was just something that should be called at the end of work and i didnt think it would matter if it was called during work.Second of all, i thought GC.Collect only affected resources that are inaccessible, or resources my program is done with. How come the application feels faster when i don't call it?Third of all, i thought the VB CLR does most of the memory cleaning for me, and that GC.Collect was somewhat of a redundant command. It didn't seem so redundant to me at all considering the difference between using it heavily and not using it at all was around 38K in memory usage!

So i guess my questions are:
1) Do I need to call GC.Collect? WhereWhen do i call it?2) Why does calling it affect performance? And where does one draw the line between that memory stat on taskmanager and the program's performance?3) I also decided to run a small test. Why does a blank vb form application require 10K memory? How accurate is that stat shown on the task manager?

View 3 Replies


ADVERTISEMENT

VS 2008 Kernel Memory - Getting Information From OS By Using Performance Counters

Jan 21, 2010

I've been trying to get memory information from the OS by using Performance Counters. Memory performance information is available from the memory manager through the system performance counters. Right now, I'm working on getting the different types of Kernel Memory, but I'm having issues getting others as well. Through Performance Counters, I've been able to get Paged Virtual and Nonpaged Kernel memory.

The article I mentioned above does not explain how to get the Paged Physical Kernel Memory. It only gives the two I mentioned and the total, which is just the two combine and isn't the Paged Physical. The information isn't straight forward, so I'm using a third party application to compare my results so that I get the correct information. The article gives me Pool Paged Bytes Kernel memory and I found out that it is the Paged Virtual Memory.

I'm declaring this and others like so: [Code] I've researched several other methods, but I can't seem to get anywhere with anything else besides Performance Counters. To sum it up, I'm looking for a method to obtain the Paged Physical Kernel Memory.

View 6 Replies

Memory By Adding Some GC.COLLECT() Calls

Dec 10, 2009

I have a windows app (2.0 framework) that's about 860k in size, just a small db app with a couple of data entry screens and a few reports (Cystal) I noticed that when the app starts the mem usage according to task manager is ~11,000k viewing just one report jumps the mem usage to 56,000k. i thought i could reclaim some of that memory by adding some GC.COLLECT() callls, but no luck. Mem usage stays the same in task manager.

So I made an even smaller test app with two forms....Form1 has two buttons , button1 Opens Form2, and button 2 calls GC.COLLECT()

From 2 contains a datagridview and 1 button. The form load for form2 executes the fill for the dataset that populates the datagridview and the button on Form 2 closes the form.

Here's the code for each form....

CODE:

No matter what I've tried so far I cannot seem to reclaim mem that gets used.

View 3 Replies

Reduce The Memory Usage Forcing To Garbage Collector To Collect With The Method?

May 1, 2012

I have a problem with an application, in this case I have a windows services. its function is generate reports depending of demand of our users.In some cases the memory usage of my windows services is to 2 gb of RAM. I disposed all objects that my application use . but the memory usage doesn't low.I tried to reduce the memory usage forcing to garbage collector to Collect with the method "GC.Collect"but it's not recommend because uses many time of CPU.Surfing on the internet I found a method named "SetProcessWorkingSetSize" that free memory usage correctly. http:[url]....but some cases my windows services named sapdkadm_procesoestandarejecucion.exe has some error message in event viewer is the next:

Faulting application sapdkadm_procesoestandarejecucion.exe, version 1.0.0.0, stamp 4f908fef, faulting module kernel32.dll, version 5.2.3790.4480, stamp 49c51cdd, debug? 0, fault address 0x0000000000027ded.

The real problem is that when this happens my windows services restart

View 3 Replies

Is There Any Real Advantage To Run A GC.collect After That Our Application Has Used A Large Quantity Of Memory Or It Is Just A Psychological Factor?

Jun 29, 2011

is there any real advantage to run a GC.collect after that our application has used a large quantity of memory or it is just a psychological factor?

View 17 Replies

.net - VB/C# Group Objects By Key - Performance (memory)?

Dec 8, 2010

I am reading from a log file.My target is to display the 10 most popular requested URL's of a website.One way to do this is to read all log entries and save each URL to a Dictionary. The dictionary has the URL as the Key and the number of visits as the Value. If a URL exists in the dictionary the Value of that URL's Key is increased +1, otherwise a new Key/Value pair is added with a value of 1.

Once the processing is finished the dictionary is sorted by Value and the top 10 entries are shown.This might work, however it could cause a serious memory problem when dealing with a log file of a website which has thousands of different page url's (think query strings).Since I only need the top 10 entries, is there a way to avoid placing all the URL's into memory and still get the top 10 URL + Visits count?

View 3 Replies

Performance In Case Of Memory Management

Nov 8, 2011

a) Dim strName as string
For i=0 to 100
strName=GetName()
do something with strname
Next

b) For i=0 to 100
Dim strName as string=GetName()
do something with strname
Next
Out of a and b which will be faster and consume less memory

Public sub GetResourceAttributes()
Dim colreSource as object
.using the colresource
colresource=nothing
end sub
Is sentencing'colresource =nothing'is good programming technique or is it enough to leave nothing done on 'colresource'. Like GC will take care of 'colresource' when there is no reference to the object.

View 2 Replies

Setup Performance Counters For CPU Usage And Memory Used?

Sep 23, 2010

I am trying to setup performance counters for CPU Usage and Memory Used.I would like a progress bar and a label to display the percentage.I have the below code and although it seems to be half working, there is something just not right.. The memory one seems to be working fine although the CPU one is acting strange.

[Code]...

View 2 Replies

VS 2010 : Setup Performance Counters For CPU Usage And Memory Used?

Sep 23, 2010

I am trying to setup performance counters for CPU Usage and Memory Used.I would like a progress bar and a label to display the percentage.I have the below code and although it seems to be half working, there is something just not right.. The memory one seems to be working fine although the CPU one is acting strange.

Shared perfTotalMemory As New ComputerInfo
Shared perfFreeMemory As New PerformanceCounter("Memory", "Available MBytes")
Shared perfProcessorTime As New PerformanceCounter("Processor", "% Processor Time", "_Total")

[code]....

View 2 Replies

VS 2008 Collect Details Regarding The Hardware And Software Of A PC?

Jun 27, 2010

How can I collect details regarding the hardware and software, of a PC? As for registration process of the product (my app), I wish to collect the details of that PC and get it saved into my server.When the client request for a new serial key, because of formatting the PC and other reasons, I would compare the PC details and will issue a new serial key based on the result. (small changes in the PC will not be considered)?

View 2 Replies

VS 2008 : Webbrowser Navigate Collect Html In Loop?

Apr 17, 2010

I have list of urls that I use a foreach loop on. I want to visit each url with the webbrowser and collect html, but the webbrowser only collects the html of the last url. I think the loop is too fast?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Collecthtml As String = ""
Dim websitelist As List(Of String) = GetURLs()

[code]....

View 1 Replies

2008 Express Edition: Attempted To Read Or Write Protected Memory, This Is Often An Indication That Other Memory Is Corrupt?

May 27, 2009

I cannot use Visual Basic 2008 at all. When I go to "new project" and choose "Windows Form Application" I get this error.I have tried multiple uninstall/reinstall with no result.A microsoft reply to this suggested that I needed: " .NET Framework 2.0 Service Pack 1 " I checked, and I did not have the .netframework 2.0 service Pack 1.
When I tried to download and install the above from Microsoft.com, the istaller said that "it was not allowsed" and I was not able to install the service pack 1.

I tried Uninstalling net framework 3.5, 3.0, 2.0 and then reinstalling .netframework 2.0 sevice pack 1; then reinstalling Visual basic 2008 express edition. At the reinstall of Visual basic 2008, .netframework 2.0 sevice pack 1 is unistalled by .net framework service pack 2.When I check the foruims for simiar problems, the formus are mostly for Visual basic 5.0, or other programs that I do not have.

Here is the programs I have installed:

Operating system: Windows XP
Microsoft .net framework 1.1
Microsoft .NET framwork 1.1 Hotfix(KB928366)
Microsoft .Net Framework 2.0 Service Pack 2

[code]....

All the security updates and hotfixes for Widows XP.

View 4 Replies

VS 2008 RTB LoadFile Performance?

Sep 22, 2010

I am working in VB.Net and loading word documents into an RTB. Most of the files I'm loading are small 2 to 60KB and have no problems. Occasionally, I have files that are upwards of 11,000KB. It takes approximately 2 minutes to get these loaded into the control. Is there anything I can do to boost performance when loading these files?

View 2 Replies

VS 2008 Resource Files And App Performance?

Nov 30, 2009

I'm not sure if I'm gonna feel like an idiot after posting this, but here goes . I have taken my first shot a writing a code generator. not too shabby for my first go round, but I already see some ways it can be vastly improved. Not there yet, however. One of the things this code generator does is pull text templates (MANY text templates! Over and OVER again!) from a project resource file. I have added them to the resource designer as linked text files.

Now, the way the generator is written, there can at times be a LOT of iteration (think writing property declarations for a Classs which represents a database entity, as well as the backing fields for those property declarations, etc.).

Is there any significant performance hit to repeatedly accessing a resource? I have looked around on msdn and this forum (and will continue to investigate), but I am hoping someone can give me some clarification.

I SUSPECT that use of a resource file means a trip to the Hard drive each time one accesses it . . . Right? It IS a FILE, linked by it's PATH, right? Due to it's having been designated as a project resource, id a resource file somehow "magially" made available in memory, so that the disk round trip is not necessary?

I suspect I should be retreiving popular resources into a persisted Class-level variable if I plan to use them often within a specific class scope, and at the method level if I plan to perform a significant number of iterations whihc require the resource within the method.

AM I on the right track, or is the resource retreival trivial? I am NOT concerned about milking maximum performance out of a generator tool; it is acceptable for this process to take a little time. However, I also don't want to be sloppy unecessarily.

View 2 Replies

[2008] Application Performance Explorer?

Mar 25, 2009

Stupid question, but how do I get access to this Explorer? To create a performance session for Windows client application:(1) Open the solution in the Visual Studio IDE. (2) On the Analyze menu, click Launch Performance Wizard.(3) From the Which of the following available targets would you like toprofile? drop-down list, select the name of the application that you wantto profile, and then click Next. You can add more binaries later

View 3 Replies

VS 2008 Network File Copy Performance?

Jun 24, 2010

I'm hoping someone can point me in a different direction. I'm copying files from one computer to another. Both are on the same switch connected at 1Gbps here's my problem:Using File.Copy with a list of files I can get an average transfer speed of ~60Mbps Using multiple background workers with a split list of files and File.Copy is slower Using the FileStream read/write method I get an average speed of ~55Mbps with a 8M buffer

What can I do to get a faster transfer rate? I'd be happy to hit 250Mbps over the LAN.

View 39 Replies

VS 2008 Performance File Read/Compare?

Sep 15, 2009

this time im looking for a faster-than-fast way to read binary files into a string/buffer/whatever, like Delphi's BlockRead does.i need this for an application that checks a list of folders/files and looks for multiple files, and handles them according to specific criteria.

I know there are standard solutions for this, like DuplicateFileRemover (gotta love that sheep! ), but i need something custommade, coz i want to handle the duplicates automatically too, and im talking about GigaBytes of data i have to periodically clean out this way..So far, the algorithm i use to determine if 2 files are equal is this:

[Code]...

View 1 Replies

VS 2008 Performance Monitor That Will Eventually Be Running As As Service

Feb 8, 2011

I am putting together a performance monitor that will eventually be running as as service. What I want to know is if the data that is reported is what I actually want: [code]

View 1 Replies

VS 2008 Thread Performance - Processor Not Running On Full Speed With The First Code?

Mar 10, 2011

Not really asking for code, but I'm interested in knowing the basics of "thread performance".For example, you try to copy a bitmap in a pixel by pixel operation. (Is slow, but it is a nice example)

[code]...

This is, of course, very buggy and causes a lot of violation errors etc. But that doesn't matter right now. How come the multi-threading way is so much faster than the regular routine? Is the processor not running on full speed with the first code, and is it working harder on the second?I find it weird to see this type of "threading performance increase", as if every single thread gets their own piece of processor speed allocated like it is a new process

View 12 Replies

[2008] Application Performance Explorer - Open The Solution In The Visual Studio IDE

Mar 25, 2009

Stupid question, but how do I get access to this Explorer? The says: To create a performance session for Windows client application:

(1) Open the solution in the Visual Studio IDE.

(2) On the <B>Analyze</B> menu, click <B>Launch Performance Wizard</B>.

(3) From the <B>Which of the following available targets would you like to profile?</B> drop-down list, select the name of the application that you want to profile, and then click <B>Next</B>. You can add more binaries later.

(4) Accept the default Sampling profiling method, and then click Next.

(5) Click <B>Finish</B>.


Only problem is that there is no <B>Analyze</B> menu in the IDE.

View 1 Replies

When And Why Need To Use GC.Collect()

Jan 24, 2012

My application waits for the user to click twice to draw a rectangle on an image, and use the rectangle to create a clone and save it. Then it restarts with the next rectangle. When I work on a large image (10800x7236) after a few cycles I get an out of memory error. but I still don't understand what's going on, and I would appreciate if some expert out there clarified why it didn't work before and it works now. This is the snippet executed after the user clicks twice, and fails after 5-6 cycles:

[Code]....

View 1 Replies

Timing Code - Measure The Performance Of Seven Sorting Algorithms In A Single VB 2008 Program

Sep 15, 2010

I'm trying to measure the performance of seven sorting algorithms in a single VB 2008 program. I've tried using a Timer componend, the Stopwatch, and DateTime.Ticks but nothing works. The following simple code produces a result of about 500 (milliseconds), which is correct, but when I change 500 to 1000, I get a ridiculous result like 0 or 8.

[Code]...

View 11 Replies

Collect A Random First And Last Name?

Mar 11, 2012

I currently have code that creates and inserts ~175,000 names into a table.

What is the quickest way to collect a random first and last name? So far I have tried, Reading from two text files where every name is one line it takes ~2:30 minutes Reading from a table with [first][last] columns takes ~4 minutes

View 4 Replies

Collect Before And After Values From A Dataset?

Sep 12, 2011

I have a multi-user app which consists of a Windows form (VS2008), and a SQL Express 2008 database. I'm already detecting if the dataset has changed before the user closes the form so I can prompt them to save their changes. What I'd like to do is to capture the changes they've made, and write them to a database table so that users can track all changes made to each record on the DB.What is the best way to grab hold of the data changes before they're written back to the DB and also grab the original records?

View 1 Replies

SQL Query Data Collect?

Nov 18, 2009

I have a SQL server table that has a list of Usernames and a list of points ranging from 1 to 10,000.I want to display the number of points in my VB.NET program from the username given. For example, if I type in "john" in the first box the program will give me a message box saying whatever amount of points "john" has. I'm not really sure about

This is the Table Structure:
Usernames Points
-----------------------------

[code].....

View 1 Replies

Loading An Image From A Jpeg That Exists In Memory (but Not On Disk) Using Direct Memory Access

Nov 5, 2009

In VB 2005, I am calling a C++ DLL function that returns the address in memory and size in bytes of a jpeg image. How can I load that jpeg image directly from memory into a picture box in my VB form? I cannot afford to save it to disk first.

View 10 Replies

Attempted To Read Or Write Protected Memory / Often An Indication That Other Memory Is Corrupt

May 22, 2007

Im getting a problem with one of my programs I have made in visual basic.NET where it gives me a memory error when i debug the program in the IDE. the exact error is this: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt". My program basically has a few forms with text fields on that get their text values from an access database on the same hard drive. Im wondering if im doing something wrong because my program just seems to eat up memory whenever it does anything. For example I have one form that has a combobox on it and when you change the drop down list selection it retreives a few strings from the database and puts them into the relevant text boxes, if you keep changing the selection then the memory usage (in task manager) just keeps going up and up. occasionally I get the error mentioned above when debugging but in my built version of the program it throws an exception everytime the memory usage gets past 49K.

Also I noticed when debugging in the "immediate window" frame I get the following message often:A first chance exception of type 'System. Invalid OperationException' occurred in System.Data.dll...Do I need to somehow be "releasing" the memory that is used to gather data once it becomes redundant?

View 12 Replies

Attempted To Read Or Write Protected Memory. This Is Often An Indication That Other Memory Is Corrupt

Nov 24, 2011

I am using the following code

This error occurs :

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Public Class FormRegEnumValue

[CODE]......................

View 2 Replies

Attempted To Read Or Write Protected Memory. This Is Often An Indication That Other Memory Is Corrupt?

Feb 1, 2009

QuoteSystem.AccessViolationException was unhandled Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt." Source="System.Windows.Forms"

Im designing a web browser and i continue to receive this error after going to about 3 websites it crashes with that error.

View 6 Replies

Necessary To Detach Event Handlers To Ensure That Memory Is Cleaned Up And That There Are Not Memory Leaks?

Jan 20, 2010

I have a BackgroundWorker object that I instantiated to perform a DB process on a background thread ansynchronously. I have event handlers for DoWork and RunWorkerCompleted. I can tell that the BackgroundWorker is disposing of itself because I added a message box into the Disposed event handler.Is it necessary to detach the event handlers to ensure that the memory is cleaned up and that there are not memory leaks?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved