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


Groups > comp.lang.c > #95299

Re: VC++ 2013, malloc() and free()

From Melzzzzz <mel@zzzzz.com>
Newsgroups comp.lang.c
Subject Re: VC++ 2013, malloc() and free()
Date 2016-10-25 18:51 +0200
Organization albasani.net
Message-ID <20161025185150.068df6e6@maxa-pc.cpe.bvcom.net> (permalink)
References (3 earlier) <numqlc$92b$1@dont-email.me> <nunqd2$c2l$5@dont-email.me> <b6e17bc9-cb19-4322-8004-53e962259bf6@googlegroups.com> <20161025172315.44bb53a4@maxa-pc.cpe.bvcom.net> <52ae27e2-0157-4f29-8ca8-cbd656f32247@googlegroups.com>

Show all headers | View raw


On Tue, 25 Oct 2016 09:09:31 -0700 (PDT)
supercat@casperkitty.com wrote:

> On Tuesday, October 25, 2016 at 10:23:23 AM UTC-5, Melzzzzz wrote:
> > Malloc is not part of the system, usually.
> > If you think about overcommit it is necessary on some setups,
> > especially for GarbageCollector based programs.  
> 
> I'm not clear on the advantages of overcommitting storage.  I can
> understand that if code allocates memory it may be advantageous for a
> paging system to defer mapping it to physical page of RAM or assigning
> its physical location in the paging file until code is going to use
> it, but I would think it should be possible to keep track of the
> quantity of outstanding requests and start refusing requests as soon
> as the number of outstanding request matches the number of free
> blocks remaining.
> 
> Trying to handle allocation failures when they occur is ugly, but
> it's at least possible to write code to recover from allocation
> failures somewhat gracefully.  If a call to malloc() may yield a
> pointer to an address that could cause a critical failure when code
> tries to use it, and if there's no requirement that applications be
> able to tell when malloc() might have done so, is there any way to
> write code that uses malloc() storage and is guaranteed not to invoke
> UB?

Concerning overcommit, malloc will almost never return NULL. There is
of course configurable limit even for overcommit.
Problem is that one can allocate more and then start to use it leading
to program termination even if malloc returned some address.
That's certainly trade-of.

-- 
press any key to continue or any other to quit

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


Thread

VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-10-24 02:20 +0800
  VC++ 2013, malloc() and free() asetofsymbols@gmail.com - 2016-10-23 11:44 -0700
    Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-10-25 12:46 +0800
      Re: VC++ 2013, malloc() and free() Melzzzzz <mel@zzzzz.com> - 2016-10-25 07:15 +0200
        Re: VC++ 2013, malloc() and free() supercat@casperkitty.com - 2016-10-25 07:15 -0700
          Re: VC++ 2013, malloc() and free() Melzzzzz <mel@zzzzz.com> - 2016-10-25 16:18 +0200
            Re: VC++ 2013, malloc() and free() supercat@casperkitty.com - 2016-10-25 07:32 -0700
              Re: VC++ 2013, malloc() and free() Melzzzzz <mel@zzzzz.com> - 2016-10-25 16:55 +0200
              Re: VC++ 2013, malloc() and free() jameskuyper@verizon.net - 2016-10-25 08:07 -0700
      Re: VC++ 2013, malloc() and free() "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-10-24 22:30 -0700
        Re: VC++ 2013, malloc() and free() Melzzzzz <mel@zzzzz.com> - 2016-10-25 07:46 +0200
          Re: VC++ 2013, malloc() and free() "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-10-25 17:54 -0700
            Re: VC++ 2013, malloc() and free() "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-10-25 17:55 -0700
        Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-10-25 22:32 +0800
          Re: VC++ 2013, malloc() and free() Melzzzzz <mel@zzzzz.com> - 2016-10-25 16:46 +0200
            Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-10-25 23:24 +0800
              Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-10-25 23:52 +0800
          Re: VC++ 2013, malloc() and free() supercat@casperkitty.com - 2016-10-25 08:01 -0700
            Re: VC++ 2013, malloc() and free() Melzzzzz <mel@zzzzz.com> - 2016-10-25 17:23 +0200
              Re: VC++ 2013, malloc() and free() supercat@casperkitty.com - 2016-10-25 09:09 -0700
                Re: VC++ 2013, malloc() and free() Keith Thompson <kst-u@mib.org> - 2016-10-25 09:29 -0700
                Re: VC++ 2013, malloc() and free() Melzzzzz <mel@zzzzz.com> - 2016-10-25 18:51 +0200
                Re: VC++ 2013, malloc() and free() raltbos@xs4all.nl (Richard Bos) - 2016-10-27 19:54 +0000
                Re: VC++ 2013, malloc() and free() supercat@casperkitty.com - 2016-10-27 15:06 -0700
                Re: VC++ 2013, malloc() and free() Keith Thompson <kst-u@mib.org> - 2016-10-27 17:06 -0700
                Re: VC++ 2013, malloc() and free() supercat@casperkitty.com - 2016-10-28 06:47 -0700
                Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-10-29 23:16 +0800
                Re: VC++ 2013, malloc() and free() supercat@casperkitty.com - 2016-10-29 09:35 -0700
                Re: VC++ 2013, malloc() and free() "James R. Kuyper" <jameskuyper@verizon.net> - 2016-10-29 12:51 -0400
                Re: VC++ 2013, malloc() and free() supercat@casperkitty.com - 2016-10-29 14:26 -0700
                Re: VC++ 2013, malloc() and free() jameskuyper@verizon.net - 2016-10-29 15:27 -0700
                Re: VC++ 2013, malloc() and free() supercat@casperkitty.com - 2016-10-29 17:11 -0700
          Re: VC++ 2013, malloc() and free() Geoff <geoff@invalid.invalid> - 2016-10-31 13:01 -0700
            Re: VC++ 2013, malloc() and free() Jerry Stuckle <jstucklex@attglobal.net> - 2016-10-31 16:35 -0400
              Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-01 15:31 +0800
                Re: VC++ 2013, malloc() and free() Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-01 11:28 -0400
      Re: VC++ 2013, malloc() and free() Geoff <geoff@invalid.invalid> - 2016-10-31 12:11 -0700
        Re: VC++ 2013, malloc() and free() supercat@casperkitty.com - 2016-10-31 13:08 -0700
  Re: VC++ 2013, malloc() and free() Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-10-23 21:35 +0100
    Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-10-25 12:49 +0800
      Re: VC++ 2013, malloc() and free() Melzzzzz <mel@zzzzz.com> - 2016-10-25 07:16 +0200
        Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-10-25 22:30 +0800
  Re: VC++ 2013, malloc() and free() "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-10-23 15:52 -0700
    Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-10-25 12:50 +0800
      Re: VC++ 2013, malloc() and free() Melzzzzz <mel@zzzzz.com> - 2016-10-25 07:18 +0200
        Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-10-25 22:28 +0800
          Re: VC++ 2013, malloc() and free() Melzzzzz <mel@zzzzz.com> - 2016-10-25 16:48 +0200
            Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-10-25 23:25 +0800
              Re: VC++ 2013, malloc() and free() Melzzzzz <mel@zzzzz.com> - 2016-10-25 17:35 +0200
                Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-10-25 23:50 +0800
                Re: VC++ 2013, malloc() and free() Melzzzzz <mel@zzzzz.com> - 2016-10-25 18:45 +0200
                Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-10-26 01:59 +0800
                Re: VC++ 2013, malloc() and free() Geoff <geoff@invalid.invalid> - 2016-10-31 12:10 -0700
                Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-01 15:32 +0800
                Re: VC++ 2013, malloc() and free() Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-01 11:31 -0400
                Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-03 19:28 +0800
                Re: VC++ 2013, malloc() and free() Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-03 10:00 -0400
                Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-03 23:25 +0800
                Re: VC++ 2013, malloc() and free() Keith Thompson <kst-u@mib.org> - 2016-11-03 09:03 -0700
                [OT] "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-04 02:33 +0800
                Re: [OT] Keith Thompson <kst-u@mib.org> - 2016-11-03 12:26 -0700
                Re: [OT] "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-04 12:05 +0800
                Re: [OT] luser droog <luser.droog@gmail.com> - 2016-11-03 21:52 -0700
                Re: [OT] "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-04 21:59 +0800
                Re: [OT] Keith Thompson <kst-u@mib.org> - 2016-11-04 08:45 -0700
                Re: [OT] James Kuyper <jameskuyper@verizon.net> - 2016-11-04 11:49 -0400
                Re: [OT] "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-05 00:33 +0800
                Re: [OT] Keith Thompson <kst-u@mib.org> - 2016-11-04 09:56 -0700
                Re: [OT] "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-05 01:40 +0800
                Re: [OT] "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-05 01:42 +0800
                Re: [OT] Keith Thompson <kst-u@mib.org> - 2016-11-04 11:52 -0700
                Re: [OT] "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-05 18:13 +0800
                Re: [OT] Keith Thompson <kst-u@mib.org> - 2016-11-05 13:19 -0700
                Re: [OT] "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-06 16:00 +0800
                Re: VC++ 2013, malloc() and free() Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-03 20:16 -0400
                Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-05 00:34 +0800
                Re: VC++ 2013, malloc() and free() supercat@casperkitty.com - 2016-11-03 08:54 -0700
                Re: VC++ 2013, malloc() and free() "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-04 02:31 +0800

csiph-web