473,385 Members | 1,400 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,385 software developers and data experts.

Following Question in C#

Hi All

I have following questions regarding C# Assembly and Threading.

Let me know the precise answer or lead me to the proper materials.

1. Is memory leakeage possible in .Net Manager Code ?
2. Is memory leakage possible in .Net Unmanaged Code ?
3. How can I find the what % of memory is being used by DLL at run time ?
4. What is difference between Sunchronous processing and Async
processing in .Net ? How can I achieve it ?
5. Can any one lead me towards Multithreading GUI development in Winforms ?
6. Difference between Delegate and Event ?
7. Is there any specific Design Patterns specifically for WinForms ?

Awaiting reply

Thanks

Silent Ocean
Nov 17 '05 #1
2 1196
Wow that is a lot of questions, with a lot of possible answers:

1. In the pure sense of the words "memory leak" there should be no way for a
managed application to leak memory. Every object or data type you create is
tracked by the .Net environment (CLR) and will be destroyed and reclaimed at
an unspecified time, this is the job of the Garbage collector. It will
periodically go through the memory map looking for objects that are no longer
in scope or referenced in the code, therefore they cannot be accessed, and
can be destroyed, this is not determinitic to the application, it is when the
GC decides it needs to try to reclaim resources it will run (you could force
it using GC.Collect(), but I would not recommend that, the garbage collector
probably knows best when it wants to run).

It is entirely possible that you write code that uses resources such as
memory / file handles / db connections etc and you do not release them
properly, i.e. you somehow keep a reference to the object, so for the
lifetime of your application you will consuming more and more resources which
will look like a kind of memory leak and you keep creating more and more
instances of the object. Look into the IDispose interface and pattern it is
pretty interesting.

2. YES - unmanaged code is not governed by the CLR, you may allocate memory
and not deallocate it therefore causing a memory leak (using languages such
as C, C++), as you are outside of managed code the CLR will have no knowledge
of this and it will not be garbage collected.

3. ???

4. In general Syncronous processing means that the caller of a method will
wait until the method which has been called has completed executing before
the caller continues executing, so for example:

Function A()
{
//Time=0 : Function A is called

//Time=1 : Call Function B, A will not continue beyond this point
//until FunctionB has completed
FunctionB();

//Time=2minutes : FunctionA now reaches this point after waiting on
FunctionB
//to complete
}
Function B()
{
//some really long processing time i.e. 2 minutes
}
An asyncronous call will call a method but the caller will not wait until
the called method returns, it will continue immediately. One example of this
is the BeginRead method of FileStream, you can request to read a section of
data, but you do not have to be blocked waiting for the read to complete,
you can continue processing other things and eventually EndRead will be
called to alert you that the read has completed.

The general pattern is that sometimes a syncronous method will have
asyncronous counterparts called BeginXXX and EndXXX, i.e. BeginInvoke,
EndInvoke, BeginRead, EndRead

5. 6. 7. Jon Skeet has some really excellent articles on this, try:
http://www.yoda.arachsys.com/csharp/...winforms.shtml
Hope that helps
Mark.
"Silent Ocean" wrote:
Hi All

I have following questions regarding C# Assembly and Threading.

Let me know the precise answer or lead me to the proper materials.

1. Is memory leakeage possible in .Net Manager Code ?
2. Is memory leakage possible in .Net Unmanaged Code ?
3. How can I find the what % of memory is being used by DLL at run time ?
4. What is difference between Sunchronous processing and Async
processing in .Net ? How can I achieve it ?
5. Can any one lead me towards Multithreading GUI development in Winforms ?
6. Difference between Delegate and Event ?
7. Is there any specific Design Patterns specifically for WinForms ?

Awaiting reply

Thanks

Silent Ocean

Nov 17 '05 #2

"Silent Ocean" <si************@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi All

I have following questions regarding C# Assembly and Threading.

Let me know the precise answer or lead me to the proper materials.

1. Is memory leakeage possible in .Net Manager Code ?
No. That would imply that the GC was buggy.

But under certain circumstances it is possible to have .NET chew all you
memory and die.

The most obvious case is if you have references in a (perhaps) static list
or hastable and forget to remove them when your done with those objects.
Hence these objects will allways be acessable by the GC and never die. This
might seem far fetched, but I have actually managed to do this twice. My
Bad. =)

If you forget to dispose of objects that should be. Streams, sockets and
database objects typically uses a lot of external unmanaged resources and if
they aren't disposed of properly; .NET will hog a lot of memory and your app
will function poorly.
2. Is memory leakage possible in .Net Unmanaged Code ?
Oh Yes. Just allocate away! =)
3. How can I find the what % of memory is being used by DLL at run time ?
Hmm. A DLL doesn't allocate memory. A process can load a DLL (an assembly)
and it's the process that allocates memory. Your question is invalid.
4. What is difference between Sunchronous processing and Async processing
in .Net ? How can I achieve it ?
Also called blocking and unblocking. Blocking code is what you usually get
when calling methods in one thread. With multithreading and callbacks you
achieve asyncronous calls. .NET has excellent support for this.
5. Can any one lead me towards Multithreading GUI development in Winforms
?
I really can't. But there are plenty of topics and books available.
6. Difference between Delegate and Event ?
A delegate is .NET construct and a reference to a method. An Event is
syntactic sugar for coupling and accessing delegates in C#.
7. Is there any specific Design Patterns specifically for WinForms ?
Not really design patterns. But there are best practices. Take a look at the
Exam books from Microsoft for certificates in .NET. They'll teach you how
it's done.
Awaiting reply
Thanks
Silent Ocean


Happy Coding
- Michael S
Nov 17 '05 #3

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

Similar topics

3
by: Peter Rohleder | last post by:
Hi, I'm using a style-sheet where I make use of the XPATH-"following-sibling"-expression. The part which makes problems looks similar to the following code: --------------------------- ...
0
by: johkar | last post by:
In the below example I am using the following to try to match only the unique MechanismText nodes within each Subscription node: select="DeliveryPreferences/DeliveryPreference" Right now, the...
10
by: Greener | last post by:
Hi, I need help badly. Can you do client-side programming instead of server-side to capture the Browser type info? If this is the case, what's wrong with the following? <script...
4
by: Greener | last post by:
May I ask you the following? Two questions about the following block of code: 1) How to open the file in NON-ReadOnly mode? I tried many things, but none of them was working. 2) Any problems...
1
by: timVerizon | last post by:
Hoping someone can help here.. Our application (C#.Net) was receiving IBM.Data.DB2.DB2Exceptions ERROR SQL0904N Unsuccessful execution caused by an unavailable resource. Reason code: '', type...
1
by: ravi | last post by:
I have created the following interest to calculate the interest for the following currency pairs. I have tried to combine them in macros using conditions but the next query that is run in the macro...
2
by: mike_li | last post by:
On Window 2000 Professional Server DB2 UDB Level: DB2 code release "SQL07029" with level identifie "030A0105" and informational tokens "DB2 v7.1.0.98", "n040510" and "WR21337". In the...
7
by: Martin Pritchard | last post by:
Hi, Sorry for my ignorance, but I'm a bit new to C++. I've been handed over a C++ app written in VS2002 which I have to convert to VS2005. Apparently it's been written in a C style, but cannot...
12
by: apicard | last post by:
I have a simple document like this: <Accept> <XXXX/> <Token image="From"/> <Date value="2007-01-01"/> <Token image="To"/> <Date value="2007-01-01"/> </Accept>
1
by: antar2 | last post by:
Hello Suppose I have a textfile (text1.txt) with following four words: Apple balcony cartridge damned paper
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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.