Results 1 to 6 of 6

Thread: [RESOLVED] 70KB app takes 10MB of RAM?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2010
    Posts
    131

    Resolved [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:
    1. Public Class Form1
    2.  
    3.     Dim drag As Boolean
    4.     Dim mousex, mousey As Integer
    5.  
    6.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    7.  
    8.         Me.SetDesktopLocation(My.Computer.Screen.Bounds.Width * 0.869, My.Computer.Screen.Bounds.Height * 0.5)
    9.  
    10.         My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).SetValue(Application.ProductName, Application.ExecutablePath)
    11.  
    12.         Timer1.Start()
    13.  
    14.     End Sub
    15.  
    16.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    17.  
    18.         Label1.Text = My.Computer.Info.AvailablePhysicalMemory / (1024 * 1024)
    19.  
    20.         Dim FreeRAM As Double = Val(Label1.Text)
    21.         FreeRAM = Math.Round(FreeRAM, 0)
    22.         Label1.Text = FreeRAM & " MB"
    23.  
    24.     End Sub
    25.  
    26.     Private Sub Form1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
    27.  
    28.         If drag Then
    29.  
    30.             Me.Top = Windows.Forms.Cursor.Position.Y - mousey
    31.  
    32.             Me.Left = Windows.Forms.Cursor.Position.X - mousex
    33.  
    34.         End If
    35.     End Sub
    36.  
    37.     Private Sub Form1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
    38.  
    39.         drag = True
    40.  
    41.         mousex = Windows.Forms.Cursor.Position.X - Me.Left
    42.  
    43.         mousey = Windows.Forms.Cursor.Position.Y - Me.Top
    44.  
    45.     End Sub
    46.  
    47.     Private Sub Form1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseClick
    48.      
    49.    drag = False
    50.      
    51.    If e.Button = MouseButtons.Right Then
    52.          
    53.   Form2.Show()
    54.      
    55.   End If
    56.  
    57.     End Sub
    58.  
    59.     Private Sub PictureBox1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
    60.      
    61.    Me.Close()
    62.  
    63.     End Sub
    64.  
    65. End Class

  2. #2
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,828

    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

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  3. #3
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    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)

  4. #4
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    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.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2010
    Posts
    131

    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.

  6. #6
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    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
  •  



Click Here to Expand Forum to Full Width