RAM usage of applications?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

RAM usage of applications?

egarrulo
Hello everybody,

I wonder if I could consider Chicken to write an application for a
device with 256 MB of RAM, where the whole RAM may not be available for
the application.

Can anybody give me a *rough* idea of how much RAM a basic program
written in Chicken and transpiled to C could require at run-time?  Some
megabytes, dozens of megabytes, etc.  With all features enabled, if
feasible.  Speed is not a concern.

Thank you.


Reply | Threaded
Open this post in threaded view
|

Fwd: RAM usage of applications?

egarrulo

EDIT: I meant 128 MB of RAM, not 256. Sorry.


-------- Messaggio Inoltrato --------
Oggetto: RAM usage of applications?
Data: Fri, 29 Nov 2019 23:19:21 +0100
Mittente: egarrulo [hidden email]
A: [hidden email]


Hello everybody,

I wonder if I could consider Chicken to write an application for a device with 256 MB of RAM, where the whole RAM may not be available for the application.

Can anybody give me a *rough* idea of how much RAM a basic program written in Chicken and transpiled to C could require at run-time?  Some megabytes, dozens of megabytes, etc.  With all features enabled, if feasible.  Speed is not a concern.

Thank you.

Reply | Threaded
Open this post in threaded view
|

Re: RAM usage of applications?

Kooda
egarrulo <[hidden email]> wrote:

> Hello everybody,
>
> I wonder if I could consider Chicken to write an application for a
> device with 256 MB of RAM, where the whole RAM may not be available for
> the application.
>
> Can anybody give me a *rough* idea of how much RAM a basic program
> written in Chicken and transpiled to C could require at run-time? Some
> megabytes, dozens of megabytes, etc.  With all features enabled, if
> feasible.  Speed is not a concern.
>
> Thank you.
What exactly do you mean by “all features enabled”?

The RAM usage is mostly determined by the program you need to write and
how you write it.

I have many programs written in CHICKEN Scheme running on a 32bits ARM
machine with only 512 MB of RAM, they all take between a few hundreds of
KB and to a few tenths of MB.
Reply | Threaded
Open this post in threaded view
|

Re: RAM usage of applications?

egarrulo
Il 30/11/19 01:21, [hidden email] ha scritto:
> egarrulo <[hidden email]> wrote:
>> Can anybody give me a *rough* idea of how much RAM a basic program
>> written in Chicken and transpiled to C could require at run-time? Some
>> megabytes, dozens of megabytes, etc.  With all features enabled, if
>> feasible.  Speed is not a concern.
> What exactly do you mean by “all features enabled”?

I mean full support for every language feature. I guess that some
language features - like "eval" and macros - may impact memory
requirements significantly. Please note that I am not a Scheme
programmer (yet).

> The RAM usage is mostly determined by the program you need to write and
> how you write it.
Sure, but there should be a lower limit, due to the runtime. For
instance, a "Hello World" program compiled with SBCL (Common Lisp) can
require dozens of megabytes. Anything else that the application does,
will add to that.
> I have many programs written in CHICKEN Scheme running on a 32bits ARM
> machine with only 512 MB of RAM, they all take between a few hundreds of
> KB and to a few tenths of MB.
That would fit my constraints.  Thank you.

Reply | Threaded
Open this post in threaded view
|

Re: RAM usage of applications?

John Cowan


On Sat, Nov 30, 2019 at 3:03 AM egarrulo <[hidden email]> wrote:
 
I mean full support for every language feature. I guess that some
language features - like "eval" and macros - may impact memory
requirements significantly. Please note that I am not a Scheme
programmer (yet).

Macros are done at compile time and cost nothing at run time.
 
Sure, but there should be a lower limit, due to the runtime. For
instance, a "Hello World" program compiled with SBCL (Common Lisp) can
require dozens of megabytes. Anything else that the application does,
will add to that.

The Scheme program (print "Hello world") compiled on Windows and stripped produces a 12K executable.  Chicken, like many other Schemes but Common Lisp, is modularized: if you don't use a feature (within reason) it is not included. 



John Cowan          http://vrici.lojban.org/~cowan        [hidden email]
May the hair on your toes never fall out!  --Thorin Oakenshield (to Bilbo)

Reply | Threaded
Open this post in threaded view
|

Re: RAM usage of applications?

Marc Feeley

> On Nov 30, 2019, at 10:07 AM, John Cowan <[hidden email]> wrote:
>
> The Scheme program (print "Hello world") compiled on Windows and stripped produces a 12K executable.  Chicken, like many other Schemes but Common Lisp, is modularized: if you don't use a feature (within reason) it is not included.
>

Interesting.  I assume the 12K excludes dependent DLLs.  Do you know if on Windows there’s a DLL for the Chicken runtime library and for the C library (and others), and their size?

Marc



Reply | Threaded
Open this post in threaded view
|

Re: RAM usage of applications?

John Cowan
On Sat, Nov 30, 2019 at 10:12 AM Marc Feeley <[hidden email]> wrote:

Interesting.  I assume the 12K excludes dependent DLLs.  Do you know if on Windows there’s a DLL for the Chicken runtime library and for the C library (and others), and their size?

The Chicken DLL is about 3.4MB, of which a good deal will be relocation tables and such.  I'm a Cygwin user, so my C library is included in cygwin1.dll, which is about the same size (it uses newlib, not glibc, but has to provide full Posix plus much other Linux stuff).  The native Windows C library, also a DLL, is about 1MB, depending on the OS version; Chicken provides the same interface on Posix and on Windows, but much of it (fork, obviously) will throw runtime exceptions on Windows.  Of course, Windows itself is also in DLLs.   Chicken does not have a run-on-bare-metal option; it depends on the presence of either Posix or Windows.



John Cowan          http://vrici.lojban.org/~cowan        [hidden email]
Yes, chili in the eye is bad, but so is your ear.  However, I would
suggest you wash your hands thoroughly before going to the toilet.
        --gadicath

Reply | Threaded
Open this post in threaded view
|

Re: RAM usage of applications?

felix.winkelmann
In reply to this post by egarrulo
> Il 30/11/19 01:21, [hidden email] ha scritto:
> > egarrulo <[hidden email]> wrote:
> >> Can anybody give me a *rough* idea of how much RAM a basic program
> >> written in Chicken and transpiled to C could require at run-time? Some
> >> megabytes, dozens of megabytes, etc.  With all features enabled, if
> >> feasible.  Speed is not a concern.
> > What exactly do you mean by “all features enabled”?
>
> I mean full support for every language feature. I guess that some
> language features - like "eval" and macros - may impact memory
> requirements significantly. Please note that I am not a Scheme
> programmer (yet).
>

On my OpenBSD system, a simple read-eval-print-loop, statically
linked to the CHICKEN runtime (libchicken.a) is 2692416 bytes.
"ps u" reports VSZ (virtual memory) 4248kb, RSS (resident memory) 4848kb
after startup. After allocating a vector of 1000000 elements and assigning
it to a variable, VSZ is 30760k, RSS 12768k. The heap grows dynamically,
but can be set to a fixed size by a runtime option. Clearing the variable
and invoking a GC leaves us with VSZ 16999kb and RSS 4955kb,
respectively.

Not sure if this helps a lot, but the size of the base image is relatively
modest, how much you can stuff into your RAM depends less on code size
but on the working set, i.e. how much memory you allocate dynamically.
CHICKEN's GC is a semispace collector where memory gets copied on GC
from one space to the other, so half of the available heap memory is unused at
any time.


felix


Reply | Threaded
Open this post in threaded view
|

Re: RAM usage of applications?

Marc Feeley
In reply to this post by John Cowan

Marc



> On Nov 30, 2019, at 10:27 AM, John Cowan <[hidden email]> wrote:
>
> On Sat, Nov 30, 2019 at 10:12 AM Marc Feeley <[hidden email]> wrote:
>
> Interesting.  I assume the 12K excludes dependent DLLs.  Do you know if on Windows there’s a DLL for the Chicken runtime library and for the C library (and others), and their size?
>
> The Chicken DLL is about 3.4MB, of which a good deal will be relocation tables and such.  I'm a Cygwin user, so my C library is included in cygwin1.dll, which is about the same size (it uses newlib, not glibc, but has to provide full Posix plus much other Linux stuff).  The native Windows C library, also a DLL, is about 1MB, depending on the OS version; Chicken provides the same interface on Posix and on Windows, but much of it (fork, obviously) will throw runtime exceptions on Windows.  Of course, Windows itself is also in DLLs.   Chicken does not have a run-on-bare-metal option; it depends on the presence of either Posix or Windows.

Thanks for the information.

So the RAM footprint at run time for the executable code (excluding the OS) will be on the order of 12KB + 3.4MB + 3.4MB + 1MB, so about 8MB.  I think that is a better measure when estimating the amount of RAM needed to run an application.  Of course to this must be added the amount of heap memory used by the program, but that is very application dependent.

Marc



Reply | Threaded
Open this post in threaded view
|

Re: RAM usage of applications?

Lassi Kortela
>> The Chicken DLL is about 3.4MB, of which a good deal will be relocation tables and such.  I'm a Cygwin user, so my C library is included in cygwin1.dll, which is about the same size [...]  The native Windows C library, also a DLL, is about 1MB, depending on the OS version [...]
>
> So the RAM footprint at run time for the executable code (excluding the OS) will be on the order of 12KB + 3.4MB + 3.4MB + 1MB, so about 8MB.  I think that is a better measure when estimating the amount of RAM needed to run an application.

The RAM taken by the DLLs ought to be shared with other running programs
using the same DLLs. If we assume the user's program is the only Chicken
program running at the time, but there are other Windows/Cygwin
programs, the Chicken program would be 12KB + 3.4MB on top of those.

Reply | Threaded
Open this post in threaded view
|

Re: RAM usage of applications?

Marc Feeley

> On Nov 30, 2019, at 10:55 AM, Lassi Kortela <[hidden email]> wrote:
>
>>> The Chicken DLL is about 3.4MB, of which a good deal will be relocation tables and such.  I'm a Cygwin user, so my C library is included in cygwin1.dll, which is about the same size [...]  The native Windows C library, also a DLL, is about 1MB, depending on the OS version [...]
>> So the RAM footprint at run time for the executable code (excluding the OS) will be on the order of 12KB + 3.4MB + 3.4MB + 1MB, so about 8MB.  I think that is a better measure when estimating the amount of RAM needed to run an application.
>
> The RAM taken by the DLLs ought to be shared with other running programs using the same DLLs. If we assume the user's program is the only Chicken program running at the time, but there are other Windows/Cygwin programs, the Chicken program would be 12KB + 3.4MB on top of those.

Indeed the level of sharing will affect the total RAM footprint.  At another extreme (the best case scenario), when there are many Scheme programs running, then the actual footprint per Scheme program will be closer to 12KB.  But my suspicion is that the situation described by egarrulo (512 MB RAM) is an embedded or dedicated system where there’s probably just one program/service running.  Anyway, in this particular case (512 MB RAM) I can’t imagine any Scheme system no being able to run with that much RAM.  For reference, many years back Gambit was able to run on a 4MB RAM nintendo DS, and that included a remote REPL over wifi.

Marc



Reply | Threaded
Open this post in threaded view
|

Re: RAM usage of applications?

John Cowan
In reply to this post by Lassi Kortela


On Sat, Nov 30, 2019 at 10:55 AM Lassi Kortela <[hidden email]> wrote:
>> The Chicken DLL is about 3.4MB, of which a good deal will be relocation tables and such.  I'm a Cygwin user, so my C library is included in cygwin1.dll, which is about the same size [...]  The native Windows C library, also a DLL, is about 1MB, depending on the OS version [...]

Cygwin1.dll doesn't use the native C library at all; it lives directly on top of the Win32 kernel and the lower-level WinNT Executive. 


>
> So the RAM footprint at run time for the executable code (excluding the OS) will be on the order of 12KB + 3.4MB + 3.4MB + 1MB, so about 8MB.  I think that is a better measure when estimating the amount of RAM needed to run an application.

I added (let loop () (loop)) after the (print "Hello world") so I could watch the process, and Windows is charging it with 2.6 MB.  I don't know how, if at all, Windows allocates DLL memory to applications with the DLL open.
 
The RAM taken by the DLLs ought to be shared with other running programs
using the same DLLs. If we assume the user's program is the only Chicken
program running at the time, but there are other Windows/Cygwin
programs, the Chicken program would be 12KB + 3.4MB on top of those.

That's my situation while running this program.



John Cowan          http://vrici.lojban.org/~cowan        [hidden email]
The first thing you learn in a lawin' family is that there ain't
no definite answers to anything.  --Calpurnia in To Kill A Mockingbird
 
Reply | Threaded
Open this post in threaded view
|

Re: RAM usage of applications?

Lassi Kortela
> I added (let loop () (loop)) after the (print "Hello world") so I could
> watch the process, and Windows is charging it with 2.6 MB.  I don't know
> how, if at all, Windows allocates DLL memory to applications with the
> DLL open.

The DLL file can be substantially larger than the runtime image if it
contains debug information, PE resources or other things that are not
loaded by default. Not sure whether that's the case here, or how to
check it on Windows.