-
Dec 8th, 2006, 05:17 PM
#1
Thread Starter
Hyperactive Member
Tons of memory usage?
Is it just me, or do .Net applications use a lot of memory, even a single-form, simple application? I made a lottery number generator that does a few things (adds items to a list, searches through the list, gets numbers, etc.), and before it even does anything it is showed using 10,000 KB of memory as soon as it starts. After every 6-number list generation, it adds on a few hundred KB, and before you know it it's reached 13 or 14 KB or more. I'd hate to see what a really involved application uses!
Is there any cause of this? Any way to prevent or regulate it that isn't extremely complex?
-
Dec 8th, 2006, 05:22 PM
#2
Addicted Member
Re: Tons of memory usage?
Well my console application is around 2,700 lines and it uses 270 KB memory usage
if a form uses too much memory probbly means you added too much open imports.
Oh ya I forgot to say that .NET has this automatic memory managment thing if you lets say minimize your application and look in task manager it will destory useless stuff without harming your app.
I wouldn't worry about it as long as you are not making a new instance of a same class which is around 200KB 50 times or something instead of using shared methods you shouldn't worry about it.
Last edited by sspoke; Dec 8th, 2006 at 05:28 PM.
-
Dec 8th, 2006, 05:27 PM
#3
Thread Starter
Hyperactive Member
Re: Tons of memory usage?
Originally Posted by sspoke
Well my console application is around 2,700 lines and it uses 270 KB memory usage
if a form uses too much memory probbly means you added too much open imports
Edit: nevermind, I googled it like I should have done in the first place: http://www.itwriting.com/dotnetmem.php
Turns out that it doesn't REALLY use 10,000 MB. After I minimize it, it only uses a few hundred KB.
Last edited by BrendanDavis; Dec 8th, 2006 at 05:34 PM.
-
Dec 8th, 2006, 05:33 PM
#4
Addicted Member
Re: Tons of memory usage?
Well sometimes you use namespaces you later realize are useless not sure if they affect performance too much well its just a theory I have every import is a dll like
System.Windows.Forms.dll System.dll .. etc.. if you use the huge ones your application will suffer more.
Turns out that it doesn't REALLY use 10,000 MB. After I minimize it, it only uses a few hundred KB.
ya lol like I said than it slowly grows again and you don't have to minimize anything it will automaticlly remove the extra bytes when your out of access memory.
Last edited by sspoke; Dec 8th, 2006 at 05:37 PM.
-
Dec 8th, 2006, 05:39 PM
#5
Re: Tons of memory usage?
That is just how WinForms are. Forms take up memory. Whether that memory is being managed effectively is a matter of both .NET and the programmer. There is a garbage collector that comes through and frees up memory every now and then automatically, the frequency of it depends on the need of the system. If there is no big need to free up memory, things might sit for a while until the garbage collector does its work. If memory is tight, it might fire more frequently. Usually if you see a continual increase in memory regardless of what you do, then it is more likely a problem with the programming. Something is not programmed correctly, objects not disposed of when they should be, etc etc... and I think im rambling too much What was the question? hehe
-
Dec 8th, 2006, 05:42 PM
#6
Thread Starter
Hyperactive Member
Re: Tons of memory usage?
Originally Posted by sspoke
Well sometimes you use namespaces you later realize are useless not sure if they affect performance too much well its just a theory I have every import is a dll like
System.Windows.Forms.dll System.dll .. etc.. if you use the huge ones your application will suffer more.
ya lol like I said than it slowly grows again and you don't have to minimize anything it will automaticlly remove the extra bytes when your out of access memory.
Yeah, I got worried for a minute there. I saw my app running for 5 minutes and growing to 15,000 KB while only doing some very simple tasks, with a very simple GUI(one list, one button) and I almost flipped.. especially since the number didn't go down after the process my app was running was complete. I always thought after a timer or loop was done, the KB usage would automatically go down. Not the case, obviously.
-
Dec 8th, 2006, 05:44 PM
#7
Thread Starter
Hyperactive Member
Re: Tons of memory usage?
A really simple, stupid question: if I declare, say, 5 items at the beginning of my code (all strings let's say, for this example).. should I have to set them to vbNullString at the end of the process, or would that not do anything?
-
Dec 8th, 2006, 05:46 PM
#8
Addicted Member
Re: Tons of memory usage?
Be creative haha sure set them if you want what you mean end of the process when your application gets terminated? if so I believe vb.net programs are safe to memory leaks it will clean everything it self.
If your program is still running setting to vbnullstring is a good idea, if its shutting down you can help it shutdown faster.. but I think it will do nothing at all.
-
Dec 8th, 2006, 06:13 PM
#9
Re: Tons of memory usage?
I agree, it will do nothing at all. I doubt setting them to null would actually speed shutdown, either. In fact, I would expect that it would slow shutdown.
My usual boring signature: Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|