Memory Usage

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

    Memory Usage

    Hello Everyone..

    Why when i build a REAAALY simples Console app with C#, when i compile
    using the realese method and execute, it already occupies almost 7mb of
    memory???

    as simple as that!!
    for(int i = 0; i<= 1000; i++)
    for(int j = 0; j<= 1000; j++)
    Console.WriteLi ne(i + "." + j);

    How to make realy light programs...like some Google programs that use
    600kb...

    Thanks!

  • Greg Young

    #2
    Re: Memory Usage

    You are not actually _using_ 7mb of memory there ... memory is allocated in
    chunks ... you then instantiate objects using bits of these chunks.. When
    the application starts up it gets memory for you to use.

    You also have the overhead in the runtime to contend with. Quite simply C#
    is the wrong tool to write a program with 600k of overhead.

    Cheers,

    Greg

    "IsRaEl" <yzraeu@gmail.c omwrote in message
    news:1158004859 .499691.187920@ d34g2000cwd.goo glegroups.com.. .
    Hello Everyone..
    >
    Why when i build a REAAALY simples Console app with C#, when i compile
    using the realese method and execute, it already occupies almost 7mb of
    memory???
    >
    as simple as that!!
    for(int i = 0; i<= 1000; i++)
    for(int j = 0; j<= 1000; j++)
    Console.WriteLi ne(i + "." + j);
    >
    How to make realy light programs...like some Google programs that use
    600kb...
    >
    Thanks!
    >

    Comment

    • Nicholas Paldino [.NET/C# MVP]

      #3
      Re: Memory Usage

      IsRaEl,

      Because you are paying for garbage collection, memory management, etc,
      etc.

      --
      - Nicholas Paldino [.NET/C# MVP]
      - mvp@spam.guard. caspershouse.co m

      "IsRaEl" <yzraeu@gmail.c omwrote in message
      news:1158004859 .499691.187920@ d34g2000cwd.goo glegroups.com.. .
      Hello Everyone..
      >
      Why when i build a REAAALY simples Console app with C#, when i compile
      using the realese method and execute, it already occupies almost 7mb of
      memory???
      >
      as simple as that!!
      for(int i = 0; i<= 1000; i++)
      for(int j = 0; j<= 1000; j++)
      Console.WriteLi ne(i + "." + j);
      >
      How to make realy light programs...like some Google programs that use
      600kb...
      >
      Thanks!
      >

      Comment

      • IsRaEl

        #4
        Re: Memory Usage

        Sooo..

        To write really light apps i should do it directly with C++ or maybe
        Python??

        Greg Young wrote:
        You are not actually _using_ 7mb of memory there ... memory is allocated in
        chunks ... you then instantiate objects using bits of these chunks.. When
        the application starts up it gets memory for you to use.
        >
        You also have the overhead in the runtime to contend with. Quite simply C#
        is the wrong tool to write a program with 600k of overhead.
        >
        Cheers,
        >
        Greg
        >
        "IsRaEl" <yzraeu@gmail.c omwrote in message
        news:1158004859 .499691.187920@ d34g2000cwd.goo glegroups.com.. .
        Hello Everyone..

        Why when i build a REAAALY simples Console app with C#, when i compile
        using the realese method and execute, it already occupies almost 7mb of
        memory???

        as simple as that!!
        for(int i = 0; i<= 1000; i++)
        for(int j = 0; j<= 1000; j++)
        Console.WriteLi ne(i + "." + j);

        How to make realy light programs...like some Google programs that use
        600kb...

        Thanks!

        Comment

        • Chris Mullins

          #5
          Re: Memory Usage

          It all depends on your definition of "really light".

          At one end of the spectrum is Assembly Language. That's gonna be pretty
          light.

          At the other end is Java and .Net, both of which require a very complex
          runtime.

          In the middle somewhere is C and C++. These two arean't always as light as
          they seem - there are all sorts of runtime libraries needed depending on the
          environment in which you're running.

          I don't really know where Python sits, but it's probably somewhere closer to
          Java and .NET than Assembly language.

          --
          Chris Mullins


          "IsRaEl" <yzraeu@gmail.c omwrote in message
          news:1158020666 .138886.27700@m 73g2000cwd.goog legroups.com...
          Sooo..
          >
          To write really light apps i should do it directly with C++ or maybe
          Python??
          >
          Greg Young wrote:
          >You are not actually _using_ 7mb of memory there ... memory is allocated
          >in
          >chunks ... you then instantiate objects using bits of these chunks.. When
          >the application starts up it gets memory for you to use.
          >>
          >You also have the overhead in the runtime to contend with. Quite simply
          >C#
          >is the wrong tool to write a program with 600k of overhead.
          >>
          >Cheers,
          >>
          >Greg
          >>
          >"IsRaEl" <yzraeu@gmail.c omwrote in message
          >news:115800485 9.499691.187920 @d34g2000cwd.go oglegroups.com. ..
          Hello Everyone..
          >
          Why when i build a REAAALY simples Console app with C#, when i compile
          using the realese method and execute, it already occupies almost 7mb of
          memory???
          >
          as simple as that!!
          for(int i = 0; i<= 1000; i++)
          for(int j = 0; j<= 1000; j++)
          Console.WriteLi ne(i + "." + j);
          >
          How to make realy light programs...like some Google programs that use
          600kb...
          >
          Thanks!
          >
          >

          Comment

          • Arne Vajhøj

            #6
            Re: Memory Usage

            IsRaEl wrote:
            To write really light apps i should do it directly with C++ or maybe
            Python??
            C is often significant lighter than C++.

            Arne

            Comment

            • Fredo

              #7
              Re: Memory Usage

              "Arne Vajhøj" <arne@vajhoej.d kwrote in message
              news:9lnNg.3767 5$_q4.36199@duk eread09...
              IsRaEl wrote:
              >To write really light apps i should do it directly with C++ or maybe
              >Python??
              >
              C is often significant lighter than C++.
              What do you base that on? C and C++ use variations of the same compiled. C++
              code can compile as tightly or almost as tightly as C code. There's very
              little difference in the size of the code generated. What libraries you use
              may have a big impact, but there's almost none between the two languages.



              Comment

              • Arne Vajhøj

                #8
                Re: Memory Usage

                Fredo wrote:
                "Arne Vajhøj" <arne@vajhoej.d kwrote in message
                >C is often significant lighter than C++.
                >
                What do you base that on? C and C++ use variations of the same compiled. C++
                code can compile as tightly or almost as tightly as C code. There's very
                little difference in the size of the code generated. What libraries you use
                may have a big impact, but there's almost none between the two languages.
                Experience.

                Try compile hello world in C and C++ and compare sizes.

                Libraries, templates and the OO style create bigger programs.

                Arne

                Comment

                Working...