473,756 Members | 5,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Memory problem

I've got this issue:
When I start my application it takes a lot of memory. I guess this is caused
by CLR.
That's fine. But every time the app performs an action (open new form, load
data in dataset, something, it doesn't matter) the memory used by the
application increases. After using it half an hour it grows so big that most
of PCs here act very slowly.

Is this behavior caused somehow by my lack of programming knowledge or
something else?
Nov 21 '05 #1
13 1524
In article <ua************ **@TK2MSFTNGP14 .phx.gbl>, Nikolay Petrov wrote:
I've got this issue:
When I start my application it takes a lot of memory. I guess this is caused
by CLR.
That's fine. But every time the app performs an action (open new form, load
data in dataset, something, it doesn't matter) the memory used by the
application increases. After using it half an hour it grows so big that most
of PCs here act very slowly.

Is this behavior caused somehow by my lack of programming knowledge or
something else?


It sounds like a resource leak - if the memory is not being released.
What version of the framework are you using? I know in 1.0 (pre-sp1, I
think) there was a memory leak caused by runtime when dealing with large
objects. I've also seen reference to some other mem leak bugs in the
framework - but they seem a little obscure... I would make sure that
you are releasing all references to module level objects and that you
are calling Dispose on any objects that implement IDisposable.

--
Tom Shelton [MVP]
Nov 21 '05 #2
What are you using to see this memory leak.

Task manager is not a good indicator.

"Nikolay Petrov" <jo******@mail. bg> wrote in message
news:ua******** ******@TK2MSFTN GP14.phx.gbl...
I've got this issue:
When I start my application it takes a lot of memory. I guess this is caused by CLR.
That's fine. But every time the app performs an action (open new form, load data in dataset, something, it doesn't matter) the memory used by the
application increases. After using it half an hour it grows so big that most of PCs here act very slowly.

Is this behavior caused somehow by my lack of programming knowledge or
something else?

Nov 21 '05 #3
I am using task manager to watch the memory usage.
Also I am using .NET Framework 1.1 SP1 - latest
And I don't think it is a memory leak or something?
Even on simpliest app with a two forms and a button where it is used to open
the second form. nothing else in the app I see this behavior.
I am calling the dispose method but it doesn't matter.

"Nikolay Petrov" <jo******@mail. bg> wrote in message
news:ua******** ******@TK2MSFTN GP14.phx.gbl...
I've got this issue:
When I start my application it takes a lot of memory. I guess this is caused by CLR.
That's fine. But every time the app performs an action (open new form, load data in dataset, something, it doesn't matter) the memory used by the
application increases. After using it half an hour it grows so big that most of PCs here act very slowly.

Is this behavior caused somehow by my lack of programming knowledge or
something else?

Nov 21 '05 #4
On Fri, 10 Sep 2004 08:38:56 +0300, Nikolay Petrov wrote:
I am using task manager to watch the memory usage.
Also I am using .NET Framework 1.1 SP1 - latest
And I don't think it is a memory leak or something?
Even on simpliest app with a two forms and a button where it is used to open
the second form. nothing else in the app I see this behavior.
I am calling the dispose method but it doesn't matter.

"Nikolay Petrov" <jo******@mail. bg> wrote in message
news:ua******** ******@TK2MSFTN GP14.phx.gbl...
I've got this issue:
When I start my application it takes a lot of memory. I guess this is

caused
by CLR.
That's fine. But every time the app performs an action (open new form,

load
data in dataset, something, it doesn't matter) the memory used by the
application increases. After using it half an hour it grows so big that

most
of PCs here act very slowly.

Is this behavior caused somehow by my lack of programming knowledge or
something else?


Nikolay... It sounds like your just observing the affects of windows
memory allocation... It always allocates more to a process then is
necessary to avoid more allocations later on (memory allocations are
expensive). If you minimize your form (before you do anything else) - you
will probably see a decrease in memory usage...

--
Tom Shelton [MVP]
Nov 21 '05 #5
You are right, after minimize the app and the maximize it again the memory
usage drop.
But after that things are the same - every click on form controls takes
memory and after some time the memory usage increases significantly. How to
prevent this behavior? I am not going to tell users to minimize thier app
from time to time. It's kind of silly.
"Tom Shelton" <to*@YOUKNOWTHE DRILLmtogden.co m> wrote in message
news:cn******** *************** ******@40tude.n et...
On Fri, 10 Sep 2004 08:38:56 +0300, Nikolay Petrov wrote:
I am using task manager to watch the memory usage.
Also I am using .NET Framework 1.1 SP1 - latest
And I don't think it is a memory leak or something?
Even on simpliest app with a two forms and a button where it is used to open the second form. nothing else in the app I see this behavior.
I am calling the dispose method but it doesn't matter.

"Nikolay Petrov" <jo******@mail. bg> wrote in message
news:ua******** ******@TK2MSFTN GP14.phx.gbl...
I've got this issue:
When I start my application it takes a lot of memory. I guess this is

caused
by CLR.
That's fine. But every time the app performs an action (open new form,

load
data in dataset, something, it doesn't matter) the memory used by the
application increases. After using it half an hour it grows so big that

most
of PCs here act very slowly.

Is this behavior caused somehow by my lack of programming knowledge or
something else?


Nikolay... It sounds like your just observing the affects of windows
memory allocation... It always allocates more to a process then is
necessary to avoid more allocations later on (memory allocations are
expensive). If you minimize your form (before you do anything else) - you
will probably see a decrease in memory usage...

--
Tom Shelton [MVP]

Nov 21 '05 #6
Nikolay,

The garbage collector collects when it is needed. When you use a form and
two buttons made by the formdesigner than Idisposable is implemented and
there should be no need to use dispose, because that is where Idisposable is
for. That there is memory used should not be of any reason why your program
is going slow, although the gc cleans (in my situation) I have seen even
when there is showed something to the screen.

However when you make by instance a routine like this,
\\\
private frmarray as new arraylist
dim frm as frm
frmarraylist.ad d(frm)
frm.open
///
You can be sure that this will create a lot of forms and never clean the
memory and the resources until you have removed the form from the arraylist
because it still has a reference.

http://msdn.microsoft.com/architectu...l/scalenet.asp

I hope this gives an idea?

Cor
Nov 21 '05 #7
On Fri, 10 Sep 2004 09:17:18 +0300, Nikolay Petrov wrote:
You are right, after minimize the app and the maximize it again the memory
usage drop.
But after that things are the same - every click on form controls takes
memory and after some time the memory usage increases significantly. How to
prevent this behavior? I am not going to tell users to minimize thier app
from time to time. It's kind of silly.


You don't have to... The behavior I was pointing out is not specific to
..NET applications. That is the way windows memory allocation works. A
process when first started is granted a larger working set then it is
expected to be used (to speed up future memory allocations). When the app
is minimized the OS reduces that working set - since the application is no
longer being used by the user.

Now, as for the growing memory... Again, you've got two main forces at
work here. You have the fact that .NET is a gc based system - which means
that memory for objects is not immediately returned to the OS. Objects are
reclaimed during a gc cycle, which is triggered when memory pressure
reaches a certain threashold. The second main factor is again - windows
memory managment. When memory that is being used by an application is
returned to the system - the, system does not necessarily remove it from
the processes working set. Again, this is because the OS figures the
process might want to allocate memory again - so, it can just reuse that
which is already allocated. If the OS needs the memory for other
applications, it will take it...

Basically, what I'm saying is that though, in general .NET apps have a
larger foot - it is not something you should be worrying about unless it is
continuing to grow without bounds and causing applications to crash due to
resource errors - this situation would be a result of a resource leak
(which is usually the result of improper management of unmanaged
resources). And in that case, you would probably want to employ a
profiling tool of some sort to help you locate the cause of the problem.

--
Tom Shelton [MVP]
Nov 21 '05 #8
Did everyone else miss what I said. Task manager is a VERY bad tool for
determinng memory allocation within .NET. That's why you have to use the
profiler. .NET Memory profiler is an excellent tool to give accurate
results (as well as see what classes are leaking).

And.. if your using any Component One Controls, thats where your leak
probably is..Because C1 Controls are garbage.

-CJ

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
Nikolay,

The garbage collector collects when it is needed. When you use a form and
two buttons made by the formdesigner than Idisposable is implemented and
there should be no need to use dispose, because that is where Idisposable is for. That there is memory used should not be of any reason why your program is going slow, although the gc cleans (in my situation) I have seen even
when there is showed something to the screen.

However when you make by instance a routine like this,
\\\
private frmarray as new arraylist
dim frm as frm
frmarraylist.ad d(frm)
frm.open
///
You can be sure that this will create a lot of forms and never clean the
memory and the resources until you have removed the form from the arraylist because it still has a reference.

http://msdn.microsoft.com/architectu...l/scalenet.asp
I hope this gives an idea?

Cor

Nov 21 '05 #9
Hi CJ,

Did I deny that with my text, I could have told it again, however did it
that often and you did that already, when I had not agreed with you I would
have put a friendly message at your message, be not afraid of that.

My message was especially not about the memory, but about the performance
my very dear friend (not sarcastic)).

:-)

Cor
Did everyone else miss what I said. Task manager is a VERY bad tool for
determinng memory allocation within .NET. That's why you have to use the
profiler. .NET Memory profiler is an excellent tool to give accurate
results (as well as see what classes are leaking).

And.. if your using any Component One Controls, thats where your leak
probably is..Because C1 Controls are garbage.

Nov 21 '05 #10

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

Similar topics

0
2048
by: Andreas Suurkuusk | last post by:
Hi, I just noticed your post in the "C# memory problem: no end for our problem?" thread. In the post you implied that I do not how the garbage collector works and that I mislead people. Since the thread is over a month old, I decided to start a new one with my response. Please see my comments inline.
4
4489
by: Amadeus | last post by:
Hello Everybody! I have a problem with MySQL servers running RedHat 9 (smp kernel 2.4.20) on Intel and MySQL server 4.0.14 (problem also appears on binary distr 4.0.15 and on 4.0.15 I bilt myself from source). I have few big tables with BLOBS and regular table 4.2 and 2.7 Gb respectively, plust several smaller tables. Every time I run query against this tables MySQL uses all available memory on server (I have 3Gb RAM on server) and it...
32
3855
by: John | last post by:
Hi all: When I run my code, I find that the memory that the code uses keeps increasing. I have a PC with 2G RAM running Debian linux. The code consumes 1.5G memory by the time it finishes execution. But I do not think it needs so much memory. About 500M memory should be enough. I have following questions about memory leak. (1).If in my code I only define constructor for my class, and do not define destructor, will it cause memory leak?
17
4813
by: José Joye | last post by:
Hi, I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I'm getting memory leak from time to time (???). In some situation, it is easier to reproduce (e.g.: remote machine not available). After about 1 day, I get a usage of 300MB of memory. I have used .NET Memory Profiler tool to try to see where the leak is located. For all the leaky instances, I can see the following (I...
16
2390
by: JCauble | last post by:
We have a large Asp.net application that is currently crashing our production servers. What we are seeing is the aspnet_wp eat up a bunch of memory and then stop unexpectedly. Does not recycle. Example: After about 5 hours with a concurrent user base of about 150 users the application raises the aspnet_wp memory usage by almost 500MB. If our server guys modify the web.config this data is released and the workerprocess goes back to a...
7
6935
by: Salvador | last post by:
Hi, I am using WMI to gather information about different computers (using win2K and win 2K3), checking common classes and also WMI load balance. My application runs every 1 minute and reports the status of the machines. Upon we follow the .NET object lifetime recommendations the application is constantly consuming more memory! The problem is on the ManagementObjectSearch, upon we Dispose the object it seems that is not releasing the...
9
9225
by: Bruno Barberi Gnecco | last post by:
I'm using PHP to run a CLI application. It's a script run by cron that parses some HTML files (with DOM XML), and I ended up using PHP to integrate with the rest of the code that already runs the website. The problem is: it's eating more memory than a black hole. It eats the current limit of 256MB set in php.ini, in an application that would hardly consume 4MB if written in C. I don't care if this application takes much longer to run...
9
4216
by: jeungster | last post by:
Hello, I'm trying to track down a memory issue with a C++ application that I'm working on: In a nutshell, the resident memory usage of my program continues to grow as the program runs. It starts off at a nice 4% of memory, then slowly grows up to 50% and beyond. This translates to around 2 gigs of physical memory, and that's really way more memory than this program should be taking up.
17
8485
by: frederic.pica | last post by:
Greets, I've some troubles getting my memory freed by python, how can I force it to release the memory ? I've tried del and gc.collect() with no success. Here is a code sample, parsing an XML file under linux python 2.4 (same problem with windows 2.5, tried with the first example) : #Python interpreter memory usage : 1.1 Mb private, 1.4 Mb shared #Using http://www.pixelbeat.org/scripts/ps_mem.py to get memory information
27
2960
by: George2 | last post by:
Hello everyone, Should I delete memory pointed by pointer a if there is bad_alloc when allocating memory in memory pointed by pointer b? I am not sure whether there will be memory leak if I do not delete a. try { a = new int ;
0
9455
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9271
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10031
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5140
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.