Solved

My program eats up a lot of memory!

Posted on 2003-11-08
4
260 Views
Last Modified: 2010-04-16
I made a small MiniWMPlayer, which is just running off the notification icon and has a WMPlayer OCX object within it.

I open my Task Manager, look up my program while it's running and playing a song, I find it's taking about 38,000K of memory usage. I run the regular Windows Media Player, I play a song, and I compare its memory usage, it only takes 5,000K! I was amazed.

Can someone help me go through the objects I have and methods I use?
Let's start with the object I have on the forms.

- 2 Form (1 frmMain for seeking/buttons/etc., 1 frmLabel to animate the song info)
- 1 NotifyIcon
- 5 Timer on frmMain; here's a list of their names and what they do:
tim = to run only once to hide frmMain at startup after 5 seconds
timLoop = loops to see if a newer instance of the app sends a new file name to this current instance (to avoid multiple instances)
timDur = to update the Duration info of the song on frmMain
timback, timforward = used to animate the main window back and forth when the user requests it to show
- 3 Timer on frmLabel; all used to animate the song info back and forth and a pause in the middle
- 1 ContextMenu
- 1 OpenFileDialog

Having that said, do they affect the memory usage at all?
0
Comment
Question by:DeuceEE
  • 2
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 100 total points
ID: 9709410
Hello

   Normal win32 app differ from .net app in this area, because .net app is managed code which require the CLR to run it and that make it take much more memory, I have some application built using Delphi which is large and big in .exe size, but take much less memory from any .Net app, because they don't require the CLR
0
 
LVL 1

Author Comment

by:DeuceEE
ID: 9709414
So if I actually make the same exact program with, say, VB6, it won't take as much?

If that's the case, a bigger project on .NET is not really memory-friendly, is it?
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 9709440
>>say, VB6, it won't take as much?
I think yes, didn't test that with VB, just with Delphi
>>a bigger project on .NET is not really memory-friendly, is it?
no, it's not like that, the small or large project will run throuth the CLR, so at small project you will feel it take much memorty than should, but you have much advantages using managed code, for example you don't need to worry about freeing your objects, the garbage collection will do that for you
also there are more features avaliable in .net platform than using VB6, it's MS Futue ;-)
0
 
LVL 1

Author Comment

by:DeuceEE
ID: 9709448
Oooh. Now that makes sense. I do appreciate the garbage collection and other features that I actually used. If memory-usage is the price for that, so be it.
Thanks :)


Free points -- for everyone!!!
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question