Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #107180

Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit?

From BartC <bc@freeuk.com>
Newsgroups comp.lang.c
Subject Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit?
Date 2017-03-27 18:14 +0100
Organization A noiseless patient Spider
Message-ID <obbh4d$10c$1@dont-email.me> (permalink)
References <b89ce929-f3e4-45f5-9043-fed71931846b@googlegroups.com> <N7aCA.122423$Ip6.7671@fx38.iad> <f2310408-850d-4945-a57f-0a63123e9f7c@googlegroups.com>

Show all headers | View raw


On 27/03/2017 17:57, Rick C. Hodgin wrote:

> Scott, I observed some behavior in Linux in 2010 that I could never
> resolve apart from the following explanation.  I've never gone further
> and investigated it though because it wasn't that big of a deal.
>
> I had a machine with 2 GB of RAM.  I was building textures in memory
> from a data file which, through the algorithm, generated 24-bit RGB
> textures.  The generated image file was about 100 MB and I used it
> for textures on this OpenGL 3D project.  I was using Ubuntu 10.04
> at the time with nothing special just default install and the basic
> build-essential environment.
>
> What I observed was the first time I loaded the data file it took the
> amount of time I would expect (many seconds) to load.  However, on
> later loads it was as though the kernel knew that I had been reading
> the disk file into allocated blocks of RAM and did not re-load them
> on subsequent passes because I had not modified their contents, but
> only read them.
>
> Is it possible Linux was designed to associate the disk reads into
> my allocated memory, observe no changes were made, and keep that data
> cached thereafter so that follow-on runs were 20x faster on load?

Doesn't any OS do that now?

I've just tested loading a 22MB file memory. It took 1.8 seconds (more 
than I expected actually). The second time it look 0.12 seconds, and 
that was on a separate run of the program.

You would expect caching anyway by the OS's file system or even by a 
disk controller.

> My only other thought was a caching hard disk, but how would it be
> able to cache about 1.5 GB worth of data?

I thought you said it was 100MB?

-- 
bartc

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? acidlategamer@gmail.com - 2017-03-27 01:23 -0700
  Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-03-27 11:06 -0400
    Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? Ken Brody <kenbrody@spamcop.net> - 2017-03-27 14:50 -0400
    Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-27 21:17 +0100
      Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? Robert Wessel <robertwessel2@yahoo.com> - 2017-03-27 19:08 -0500
  Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? scott@slp53.sl.home (Scott Lurndal) - 2017-03-27 15:23 +0000
    Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-03-27 09:57 -0700
      Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? BartC <bc@freeuk.com> - 2017-03-27 18:14 +0100
  Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? gordonb.l1p2g@burditt.org (Gordon Burditt) - 2017-03-27 12:37 -0500
    Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-03-27 13:53 -0400
    Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? scott@slp53.sl.home (Scott Lurndal) - 2017-03-27 18:06 +0000
    Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? supercat@casperkitty.com - 2017-03-27 12:29 -0700
      Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? Robert Wessel <robertwessel2@yahoo.com> - 2017-03-27 19:04 -0500
        Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? supercat@casperkitty.com - 2017-03-27 17:31 -0700
          Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? Ian Collins <ian-news@hotmail.com> - 2017-03-28 13:35 +1300
        Re: Does heap segment of a C program increases in the amount of RAM or is it fixed to a limit? Ian Collins <ian-news@hotmail.com> - 2017-03-28 13:37 +1300

csiph-web