abnormal memory occupation?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ziphyre

    abnormal memory occupation?

    Hi,

    I have a simple windows application, it doen't have any form, or
    expensive resource, just a simple exe. Its size compiled in release mode
    is approximately 23KB. But when I run it, its size on memory is approx
    12MB (megabyte!!!). Here is a simplified version of the code, I'll be
    more than happy if you could tell me is this normal, or what can cause
    the problem

    Thanks


    using System.Text;
    using System.IO;
    using System.Collecti ons.Specialized ;
    using System.Web;
    using System.Threadin g;

    public class AutoBuy
    {
    public static void Main()
    {
    while ( true )
    {
    CommTest.GetDat a();
    Thread.Sleep(30 00000);
    }
    }
    }


    public class CommTest
    {
    public static void GetData()
    {
    //... declaration of 3 string
    HttpWebRequest hreq = CreateKocGETReq uest();
    //mark1
    HttpWebResponse hresp = (HttpWebRespons e) req.GetResponse ();
    StreamReader respReader = new
    StreamReader(hr esp.GetResponse Stream());
    rstring = respReader.Read ToEnd();
    respReader.Clos e();
    hresp.Close();
    //mark2

    hreq = CreateKocPOSTRe quest("login.ph p", ckyString,
    byteArray);

    //again mark1 to mark2 with different data, nothing
    //special

    }

    public static CookieCollectio n GetCookies(WebH eaderCollection
    hdCol)
    {
    //a function which extracts 3 cookies from header files
    //works only with int and string's

    return ckyCol;
    }

    public static string GetHash(string s)
    {
    //another function just with ints and strings

    return astring;
    }

    public static HttpWebRequest CreateKocGETReq uest()
    {
    HttpWebRequest KocReq = (HttpWebRequest )
    WebRequest.Crea te("http://www.temp.com");
    //sets 5 five properties

    return KocReq;
    }


    public static HttpWebRequest CreateKocPOSTRe quest(string path,
    string ckyString, byte[] postData)
    {
    HttpWebRequest KocReq = (HttpWebRequest )
    WebRequest.Crea te("http://www.temp.com/" +
    path);

    //sets 7 properties with strings
    return KocReq;
    }
    }
  • Anders Borum

    #2
    Re: abnormal memory occupation?

    Hello Ziphyre

    This is caused by the CLR thats responsible for loading the required
    application. Currently there's a footprint of about 12 MB, but if I
    understand Jason Zander from the CLR team correctly, this is something
    they're working on (as well as startup times).

    Not sure it'll be better with .NET 2.0, but I'm sure they're doing their
    very best (in all aspects of the .NET framework actually).

    --
    venlig hilsen / with regards
    anders borum
    --


    Comment

    • Ian Griffiths [C# MVP]

      #3
      Re: abnormal memory occupation?

      Strictly speaking, the minimum working set footprint of the CLR is more like
      5.5MB, in my experience.

      However, that goes up as soon as you start using certain bits of the .NET
      Framework. There are lots of pieces of it that have a substantial hit as
      soon as you use them. Windows Forms, for example.

      So 12MB is not unusual for a Windows forms application that does nothing.

      --
      Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
      DevelopMentor - http://www.develop.com/

      "Anders Borum" <anders@spherew orks.dk> wrote:[color=blue]
      >
      > This is caused by the CLR thats responsible for loading the required
      > application. Currently there's a footprint of about 12 MB, but if I
      > understand Jason Zander from the CLR team correctly, this is something
      > they're working on (as well as startup times).
      >
      > Not sure it'll be better with .NET 2.0, but I'm sure they're doing their
      > very best (in all aspects of the .NET framework actually).[/color]


      Comment

      • Jon Skeet [C# MVP]

        #4
        Re: abnormal memory occupation?

        Ziphyre <nospam@yahoo.c om> wrote:[color=blue]
        > I have a simple windows application, it doen't have any form, or
        > expensive resource, just a simple exe. Its size compiled in release mode
        > is approximately 23KB. But when I run it, its size on memory is approx
        > 12MB (megabyte!!!). Here is a simplified version of the code, I'll be
        > more than happy if you could tell me is this normal, or what can cause
        > the problem[/color]

        That sounds a little high, but not huge. There's a significant initial
        memory use in .NET (even a program which *just* sleeps for 10 seconds
        takes about 3.5MB on my box) but you should find that as your program
        gets larger, your memory requirements don't go up by much more than you
        expect - in other words, there's a large initial usage, but it's not
        particularly inefficient in terms of actual data.

        --
        Jon Skeet - <skeet@pobox.co m>
        Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

        If replying to the group, please do not mail me too

        Comment

        • Ziphyre

          #5
          Re: abnormal memory occupation?

          Thanks for the answers, i was pretty sure that somethings were wrong but
          it's quite reasonable when you put it that way

          thanks again

          Ziphyre wrote:[color=blue]
          > Hi,
          >
          > I have a simple windows application, it doen't have any form, or
          > expensive resource, just a simple exe. Its size compiled in release mode
          > is approximately 23KB. But when I run it, its size on memory is approx
          > 12MB (megabyte!!!). Here is a simplified version of the code, I'll be
          > more than happy if you could tell me is this normal, or what can cause
          > the problem
          >
          > Thanks
          >[/color]

          Comment

          • Willy Denoyette [MVP]

            #6
            Re: abnormal memory occupation?

            And to add what others said, don't ever compare file size of your assembly
            with memory consumption, both are not related.

            Willy.

            "Ziphyre" <nospam@yahoo.c om> wrote in message
            news:30lug7F2v7 ij6U1@uni-berlin.de...[color=blue]
            > Thanks for the answers, i was pretty sure that somethings were wrong but
            > it's quite reasonable when you put it that way
            >
            > thanks again
            >
            > Ziphyre wrote:[color=green]
            >> Hi,
            >>
            >> I have a simple windows application, it doen't have any form, or
            >> expensive resource, just a simple exe. Its size compiled in release mode
            >> is approximately 23KB. But when I run it, its size on memory is approx
            >> 12MB (megabyte!!!). Here is a simplified version of the code, I'll be
            >> more than happy if you could tell me is this normal, or what can cause
            >> the problem
            >>
            >> Thanks
            >>[/color][/color]


            Comment

            • Willy Denoyette [MVP]

              #7
              Re: abnormal memory occupation?

              The footprint in v2.0 is a bit higher, because the modules loaded are
              getting larger in v2.
              The good news is that much of the Framework is now mapped to shared pages,
              which considerably reduces total memory consumption when multiple .NET
              applications are loaded.

              Willy.


              "Anders Borum" <anders@spherew orks.dk> wrote in message
              news:uH2iist0EH A.2876@TK2MSFTN GP12.phx.gbl...[color=blue]
              > Hello Ziphyre
              >
              > This is caused by the CLR thats responsible for loading the required
              > application. Currently there's a footprint of about 12 MB, but if I
              > understand Jason Zander from the CLR team correctly, this is something
              > they're working on (as well as startup times).
              >
              > Not sure it'll be better with .NET 2.0, but I'm sure they're doing their
              > very best (in all aspects of the .NET framework actually).
              >
              > --
              > venlig hilsen / with regards
              > anders borum
              > --
              >
              >[/color]


              Comment

              Working...