-
Jul 4th, 2011, 02:44 PM
#1
Thread Starter
Addicted Member
[RESOLVED] 70KB app takes 10MB of RAM?
Was just wondering, why would a 70KB application takes almost 10MB of RAM? All the application does is that it shows the amount fo FREE RAM my computer has. It has 2 pictures, an icon and 2 labels. The amount remains the same, it doesn't increase with the passing of time, I just think such a small application shouldn't eat that much memory.
All code is below:
vb.net Code:
Public Class Form1
Dim drag As Boolean
Dim mousex, mousey As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.SetDesktopLocation(My.Computer.Screen.Bounds.Width * 0.869, My.Computer.Screen.Bounds.Height * 0.5)
My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).SetValue(Application.ProductName, Application.ExecutablePath)
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = My.Computer.Info.AvailablePhysicalMemory / (1024 * 1024)
Dim FreeRAM As Double = Val(Label1.Text)
FreeRAM = Math.Round(FreeRAM, 0)
Label1.Text = FreeRAM & " MB"
End Sub
Private Sub Form1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
If drag Then
Me.Top = Windows.Forms.Cursor.Position.Y - mousey
Me.Left = Windows.Forms.Cursor.Position.X - mousex
End If
End Sub
Private Sub Form1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
drag = True
mousex = Windows.Forms.Cursor.Position.X - Me.Left
mousey = Windows.Forms.Cursor.Position.Y - Me.Top
End Sub
Private Sub Form1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseClick
drag = False
If e.Button = MouseButtons.Right Then
Form2.Show()
End If
End Sub
Private Sub PictureBox1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
Me.Close()
End Sub
End Class
-
Jul 4th, 2011, 06:15 PM
#2
Re: 70KB app takes 10MB of RAM?
The size of your app has nothing to do with how much memory it will take up. Really though, 10K isn't all that bad. I have an app, which has thousands of lines of code and perform a bunch of operations during startup and takes up 15K. But, it runs perfectly.
Even during heavy operation, it doesn't top 25K. So, for an app that is constantly querying data like yours is to only take up 10K, is not that big of a deal.
CodeBank contributions: Process Manager, Temp File Cleaner
Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Jul 4th, 2011, 06:58 PM
#3
Re: 70KB app takes 10MB of RAM?
That 10MB will also include any parts of the .NET framework that are loaded. Memory consumption really isn't as simple as a single number any more (and hasn't been for a looong time)
-
Jul 4th, 2011, 08:11 PM
#4
Re: 70KB app takes 10MB of RAM?
What you can't see is the thousands of lines of framework code it takes to load a teeny old .NET application. It's irrelevant on modern machines. 10MB is barely a decimal point of a percentage of most peoples' RAM. The rule of thumb these days is don't worry about memory until you've measured a performance problem. Premature optimization is a great evil.
Besides, your method of measuring memory usage isn't very good. You're just looking at the system's free physical memory; if some system service (like Windows Update) starts running, you'll see a drop that has nothing to do with your application.
-
Jul 5th, 2011, 08:17 AM
#5
Thread Starter
Addicted Member
Re: 70KB app takes 10MB of RAM?
@Sitten Spynne, I don't want to check my application's RAM, I want to check the overall free RAM in my computer periodically, and it's not like 10MB is too much to me, as I think 4 GB of RAM that I have is more than enough to handle it, but I've seen .Net applications take like 300KB of RAM, and I wonder why mine would take this much, but I guess those lines of framework eat most of the memory as you said.
-
Jul 5th, 2011, 03:24 PM
#6
Fanatic Member
Re: [RESOLVED] 70KB app takes 10MB of RAM?
Some info:
100% clean Forms application: 8,875 mb RAM
Forms application with 256x256 white background BMP image: 9,724 mb RAM
Doublebuffered Forms application with 256x256 white background BMP image: 9,764 mb RAM (almost the same)
Console apps with a do loop
100% clean Console application: 7,424 mb
100% clean Console application w/o references: 4,888 mb
Even the minimalist of apps take up too much memory, since the system has lots of free memory to spend anyways. See it as the OS paying everyone a lot since it has lots to spend, but when in an economical crisis it will scarcely give everyone some.
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
|