473,378 Members | 1,429 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Garbage Collecting and real-time processing.

Hello, can someone please give me a tip or two on the following problem:

I have a system of linked objects which stores properties of on-screen drawn objects. When i select each object on the screen the application slowly over 10-20 seconds grows slower, and the computer runs out of memory so the disk starts spinning and the garbage collector does its thing, problem is that the applicatoin requires a bit more real-time processing and the user gets a frozen screen for 2-3 seconds at a time if not more.

Should i call the following code before someone clicks on my on-screen object so that i can release any previous allocated memory?

GC.Collect();
GC.WaitForPendingFinilizers();
GC.Collect();

Is this the only way to "Hope/pray" for a speed up?
Nov 16 '05 #1
3 1547
Hey there -

First - GC.Collect() is something you shouldn't use in a production
enviornment.

Second - if the response time is so slow, maybe you should start thinking
about a change of the design, or some of the technologies that you're
using - for example - separate the linked list operations on a different
thread, so the UI can continue to repaint, while the other thread walks
through the list. Then use a callback or something else so you can inform
the main thread about the result of the operation.

Third - You should ask yourself the following questions before starting to
search for anything else:
How big is exactly the list?
How much memory it consumes?
How big you expect the list the become?
Are you sure there are not cross references, between different nodes and
you're not going into an endless cycle?

Cheers,
Branimir
--
Branimir Giurov
MCSD.NET, MCDBA
"CSharpX" <an*******@discussions.microsoft.com> wrote in message
news:39**********************************@microsof t.com...
Hello, can someone please give me a tip or two on the following problem:

I have a system of linked objects which stores properties of on-screen drawn objects. When i select each object on the screen the application
slowly over 10-20 seconds grows slower, and the computer runs out of memory
so the disk starts spinning and the garbage collector does its thing,
problem is that the applicatoin requires a bit more real-time processing and
the user gets a frozen screen for 2-3 seconds at a time if not more.
Should i call the following code before someone clicks on my on-screen object so that i can release any previous allocated memory?
GC.Collect();
GC.WaitForPendingFinilizers();
GC.Collect();

Is this the only way to "Hope/pray" for a speed up?

Nov 16 '05 #2
Thanks for the tip
but the problem is that i use up a lot of memory while selecting my objects on the screen, and the memory just gets taken and never released so after a couple times through the selecting of the objects on the screen memory runs out and the GC kicks in automatically and slows down everything to a crawl.

i added the 3 lines, and i solved my problem.
I no longer have memory taken and never released. If i had cross-referenced objects then the 3 lines of code woudln't free the memory no matter what, but they do, my memory usage stays constant at 20-30MB, before that, i'd consume as much memory as my system had.
Nov 16 '05 #3

"CSharpX" <an*******@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
Thanks for the tip, i added the 3 lines, and i solved my problem.
I no longer have memory taken and never released. If i had
cross-referenced objects then the 3 lines of code woudln't free the memory
no matter what, but they do, my memory usage stays constant at 20-30MB,
before that, i'd consume as much memory as my system had.


You mean that forcing a collection releases the memory while an induced
collection doesn't release it? This is simply not possible, the GC run's
more frequently than you think, just watch the CLR memory counters using
perfmon, and use a CLR memory profiler to check your allocation patterns.
When using perfmon, the counters you should watch are the GC0, GC1 and GC2
collections for .NET CLR Memory -object, you should try to have the GC2
collections number as small as possible, you should also a CLR memory
profiler to see what objects getting relocated.

One thing to keep in mind is, that there must be something wrong with your
code when you need to call GC.Collect() .

Willy.
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Robert Potthast | last post by:
Hi! I am trying to implement a safe garbage collecting system. I use reference counting combined with smart pointers and a garbage collector which keeps a list of all heap-allocated objects. Now I...
34
by: Ville Voipio | last post by:
I would need to make some high-reliability software running on Linux in an embedded system. Performance (or lack of it) is not an issue, reliability is. The piece of software is rather simple,...
8
by: Martin Maat | last post by:
I am puzzled. I have this object that uses a thread. The thread is encapsulated by the object, the object has Start and Stop methods to enable the client to start or stop the thread. I found...
4
by: Nadav | last post by:
Hi I wonder... does installing .NET framework may effect the performance of native process running on the same computer Does the GC runs in the kernel or in the application layer? running the GC...
9
by: Olivier Fermy | last post by:
I have created a sample project where i have referenced an object only with an event : textBox.VisibleChanged += new EventHandler(this.textBox_VisibleChanged); When i call GC.Collect(), the...
5
by: Hyun-jik Bae | last post by:
I got a curiosity while using CLR. How can it be done that accessing object data by CLR application is safe even while garbage collector is working? Is the GC thread running in realtime priority...
8
by: Paul.Lee.1971 | last post by:
Hi everyone, A program that I'm helping to code seems to slow down drastically during initialisation, and looking at the profiling graph, it seems to be the garbage collector thats slowing things...
9
by: amygdala | last post by:
Hi, I've read a few threads in this group recently, discussing garbage collecting and unsetting variables and the likes. Concerning memory usage in PHP: what is good practice, i.e. what should I...
3
by: R Karthick | last post by:
Hi, I am in the process of designing a conservative garbage collector for C ++. As one of the requirement of conservative garbage collection, I will have to scan through the static memory...
3
by: from.future.import | last post by:
Hi, I encountered garbage collection behaviour that I didn't expect when using a recursive function inside another function: the definition of the inner function seems to contain a circular...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.