Re: Setting memory allocators for library functions.

2001-02-28 Thread Jos Backus
For your collective amusement, here's a post that talks about how OS/2 handles memory allocation. DosAllocMem() has a flags argument, and one of the flags requests the OS to actually commit the memory. http://w3.hethmon.com/os2isp/1998/Apr/Msgs/l2w96957.html http://www.stidolph.com/os2ap

Re: Setting memory allocators for library functions.

2001-02-28 Thread Arun Sharma
On Tue, Feb 27, 2001 at 10:39:13PM -0800, Julian Elischer wrote: > no, something specifically designed around kernel type of actions. > declarations of "physical pointer", "kvm pointer" "User Pointer" > for example, and being able to declare a structure (not 'struct') > and say "this list is 'per

Re: Setting memory allocators for library functions.

2001-02-28 Thread Dag-Erling Smorgrav
Tony Finch <[EMAIL PROTECTED]> writes: > What about setrlimit(RLIMIMT_DATA)? Yep, I'd forgotten about that. Malloc() will return NULL if you hit your data size limit. DES -- Dag-Erling Smorgrav - [EMAIL PROTECTED] To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers

Re: Setting memory allocators for library functions.

2001-02-28 Thread michael schuster
Matt Dillon wrote: > Allowing a program to run the OS itself out of VM, with or without > overcommit, is (being generous) just plain dumb. I'm not a fan of either (overcommit or non-), I can see advantages with both (seeing that Solaris, which I happen to work with, has one and FreeBSD t

Re: Setting memory allocators for library functions.

2001-02-27 Thread Julian Elischer
Wes Peters wrote: > > Julian Elischer wrote: > > > > Arun Sharma wrote: > > > > > > On 26 Feb 2001 18:56:18 +0100, Matt Dillon <[EMAIL PROTECTED]> wrote: > > > > Ha. Right. Go through any piece of significant code and just see how > > > > much goes flying out the window because the code

Re: Setting memory allocators for library functions.

2001-02-27 Thread Wes Peters
Julian Elischer wrote: > > Arun Sharma wrote: > > > > On 26 Feb 2001 18:56:18 +0100, Matt Dillon <[EMAIL PROTECTED]> wrote: > > > Ha. Right. Go through any piece of significant code and just see how > > > much goes flying out the window because the code wants to simply assume > > >

Re: [hackers] Re: Setting memory allocators for library functions.

2001-02-27 Thread Tony Finch
Maxime Henrion <[EMAIL PROTECTED]> wrote: >Tony Finch wrote: >> >> If it's available at all, mprotect() is often limited to memory >> obtained with mmap(), i.e. not malloc(). Not great for portability. > >FreeBSD malloc() calls mmap() as AFAIK many (if not all) malloc() >implementations. FreeBSD

Re: [hackers] Re: Setting memory allocators for library functions.

2001-02-27 Thread Maxime Henrion
Tony Finch wrote: > Drew Eckhardt <[EMAIL PROTECTED]> wrote: > >In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] writes: > >>In most cases it is impossible to declare the data read-only because > >>it originally had to be read-write and you can't change its attributes > >>later. > > > >mprotect(

Re: [hackers] Re: Setting memory allocators for library functions.

2001-02-27 Thread Tony Finch
Drew Eckhardt <[EMAIL PROTECTED]> wrote: >In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] writes: >>In most cases it is impossible to declare the data read-only because >>it originally had to be read-write and you can't change its attributes >>later. > >mprotect(2). If it's available at all, m

Re: [hackers] Re: Setting memory allocators for library functions.

2001-02-27 Thread Drew Eckhardt
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] writes: >In most cases it is impossible to declare the data read-only because >it originally had to be read-write and you can't change its attributes >later. mprotect(2). To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-

Re: [hackers] Re: Setting memory allocators for library functions.

2001-02-27 Thread Tony Finch
Lyndon Nerenberg <[EMAIL PROTECTED]> wrote: > >If the information in the data segment is going to be updated then >you have to have writable backing store. If, however, that data >is never going to be changed, it should be declared in the program >as read-only data. The kernel VM system should not

Re: Setting memory allocators for library functions.

2001-02-27 Thread Daniel C. Sobral
Tony Finch wrote: > > >It doesn't trash. The memory is filled with backtracking information. > >Memory in active use at any time is rather small. > > I've read articles about programs which use GC which have a small > working set, although it is constantly changing (I've heard of > programs allo

Re: Setting memory allocators for library functions.

2001-02-27 Thread Tony Finch
"Daniel C. Sobral" <[EMAIL PROTECTED]> wrote: >Matt Dillon wrote: >> >> What is the point of running a scientific calculation if the >> machine turns into a sludge pile and would otherwise cause the >> calculation to take years to complete instead of days? > >It doesn't trash. The memo

Re: [hackers] Re: Setting memory allocators for library functions.

2001-02-27 Thread Lyndon Nerenberg
> "Tony" == Tony Finch <[EMAIL PROTECTED]> writes: >> Well, to some extent, I have to wonder why all these pages are >> being requested if they aren't being used... Tony> fork() with big data segments that cause swap to be reserved Tony> in case of a copy-on-write. The 2GB o

Re: [hackers] Re: Setting memory allocators for library functions.

2001-02-27 Thread Tony Finch
Peter Seebach <[EMAIL PROTECTED]> wrote: >David Gilbert writes: >> >>Due to the bloat of the OS and Motif and other such things, they >>required simply amazing amounts of swap just to run. > >Well, to some extent, I have to wonder why all these pages are being >requested if they aren't being used.

Re: Setting memory allocators for library functions.

2001-02-27 Thread Tony Finch
Dag-Erling Smorgrav <[EMAIL PROTECTED]> wrote: > >This is all academic since FreeBSD does memory overcommit, so unless >you run out of address space for your process before you run out of >actual memory and/or swap (not likely, but quite possible) malloc() >will never return NULL and you won't kno

Re: Setting memory allocators for library functions.

2001-02-27 Thread Jonas Bulow
Peter Seebach wrote: ... > Imagine a word processor with this behavior. No attempt to save your > file, no nothing, it just suddenly closes all windows and dies. I think most people can think of at least one widely used commerical word processor with exactly this behaviour. :-) To Unsubscribe:

Re: Setting memory allocators for library functions.

2001-02-27 Thread Matt Dillon
Daniel, you don't have to believe me, I really don't care. I hear this argument once or twice a year and those of who actually have experience (except for Terry, who always likes to argue theory) already know what the reality is. Come back in a year or two after you've wasted a t

Re: Setting memory allocators for library functions.

2001-02-27 Thread Julian Elischer
Arun Sharma wrote: > > On 26 Feb 2001 18:56:18 +0100, Matt Dillon <[EMAIL PROTECTED]> wrote: > > Ha. Right. Go through any piece of significant code and just see how > > much goes flying out the window because the code wants to simply assume > > things work. Then try coding conditi

Re: Setting memory allocators for library functions.

2001-02-27 Thread Daniel C. Sobral
Matt Dillon wrote: > > Said application was poorly written, then. Even on solaris if you The only reason the application was "poorly written" is the overcommit architecture. > actually run the system out of memory you can blow up other unrelated > processes. To depend on that sort

Re: Setting memory allocators for library functions.

2001-02-27 Thread Matt Dillon
:> things work. Then try coding conditionals all the way through to fix :> it... and don't forget you need to propogate the error condition back :> up the procedure chain too so the original caller knows why it failed. : :So, it all comes down to reimplementing the UNIX kernel in a l

Re: Setting memory allocators for library functions.

2001-02-26 Thread Arun Sharma
On 26 Feb 2001 18:56:18 +0100, Matt Dillon <[EMAIL PROTECTED]> wrote: > Ha. Right. Go through any piece of significant code and just see how > much goes flying out the window because the code wants to simply assume > things work. Then try coding conditionals all the way through to f

Re: [hackers] Re: Setting memory allocators for library functions.

2001-02-26 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Tony Finch writes: >fork() with big data segments that cause swap to be reserved in case >of a copy-on-write. The 2GB of swap is never actually used, but you >still have to have it. That's a good point. So, we should warn people that asking for memory committments

Re: Setting memory allocators for library functions.

2001-02-26 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Rik van Riel writes: >Rationale: >SIGSEGV for _user_ mistakes (process accesses wrong stuff) >SIGBUS for _system_ errors (ECC error, kernel messes up, ...) Actually, this is not canonically the distinction made. On a Unix PC, { int *a, c[

Re: Setting memory allocators for library functions.

2001-02-26 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Rik van Riel writes: >I don't think a failed kernel-level allocation after overcommit >should generate a segfault. >IMHO it should send a bus error (or a sigkill if the process >doesn't exit after the SIGBUS). Same difference, so far as the language is concerned.

Re: Setting memory allocators for library functions.

2001-02-26 Thread Rik van Riel
On Mon, 26 Feb 2001, Peter Seebach wrote: > In message <[EMAIL PROTECTED]>, > >And maybe, just maybe, they'll succeed in getting their > >idea of non-overcommit working with a patch which doesn't > >change dozens of places in the kernel and doesn't add > >any measurable overhead. > > If it adds ov

[hackers] Re: Setting memory allocators for library functions.

2001-02-26 Thread David Gilbert
> "Daniel" == Daniel C Sobral <[EMAIL PROTECTED]> writes: Daniel> Dag-Erling Smorgrav wrote: >> > > None of these solutions are portable, however; > Well, no, but >> the sole available definition of "portable" says that it is > >> "portable" to assume that all the memory malloc can return is

Re: Setting memory allocators for library functions.

2001-02-26 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, >And maybe, just maybe, they'll succeed in getting their >idea of non-overcommit working with a patch which doesn't >change dozens of places in the kernel and doesn't add >any measurable overhead. If it adds overhead, fine, make it a kernel option. :) Anyway, no

Re: Setting memory allocators for library functions.

2001-02-26 Thread Rik van Riel
On Tue, 27 Feb 2001, Daniel C. Sobral wrote: > Matt Dillon wrote: > > :Matt Dillon wrote: > > :> > > :.. > > :> the system runs out of memory, even *with* overcommit protection. > > :> In fact, all sorts of side effects occur even when the system > > :... > > : > > :That's an assumption. >

Re: Setting memory allocators for library functions.

2001-02-26 Thread Rik van Riel
On Sun, 25 Feb 2001, Matt Dillon wrote: > The problem is a whole lot more complex then you think. Dealing with > overcommit is not simply counting mapped pages, there are all sorts > of issues involved. But the biggest gotcha is that putting in > overcommit protection will not a

Re: Setting memory allocators for library functions.

2001-02-26 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, "Daniel C. Sobral" writes: >Anyway, these are two very different situations, and comparing them is >silly. They are situations in which an application can be killed and has no way to detect that it is about to do something wrong, and in which there *was* a correct

Re: Setting memory allocators for library functions.

2001-02-26 Thread Matt Dillon
:> :... :> : :> :That's an assumption. :> :> Ha. Right. Go through any piece of significant code and just see how :> much goes flying out the window because the code wants to simply assume :> things work. Then try coding conditionals all the way through to fix :> it... and don

Re: Setting memory allocators for library functions.

2001-02-26 Thread Daniel C. Sobral
Matt Dillon wrote: > > :Matt Dillon wrote: > :> > :.. > :> the system runs out of memory, even *with* overcommit protection. > :> In fact, all sorts of side effects occur even when the system > :... > : > :That's an assumption. > > Ha. Right. Go through any piece of significant cod

Re: Setting memory allocators for library functions.

2001-02-26 Thread Daniel C. Sobral
Peter Seebach wrote: > > It's odd that I see lots of people arguing for segfaults killing the process > accessing memory that has been "successfully" allocated, but no one arguing > for the process getting killed when it exceeds a disk quota. Disk quote is an artificial limit. If you remind each

Re: Setting memory allocators for library functions.

2001-02-26 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Matt Dillon writes: > This has nothing to do with overcommit in the context it is being > discussed. In fact, this has nothing to do with OS memory management > at all -- all garbage collected languages have their own infrastructure > to determine when memo

Re: Setting memory allocators for library functions.

2001-02-26 Thread Peter Dufault
> > I still think that in such a case it should be possible to > 'test the commitment' by touching all the allocated memory > while trapping page faults. and fault all your memory from > 'potential' to 'allocated'. As someone said. it is not sure which program > when you run out of swap, but I

Re: Setting memory allocators for library functions.

2001-02-26 Thread Matt Dillon
:Matt Dillon wrote: :> :.. :> the system runs out of memory, even *with* overcommit protection. :> In fact, all sorts of side effects occur even when the system :... : :That's an assumption. Ha. Right. Go through any piece of significant code and just see how much goes flying

Re: Setting memory allocators for library functions.

2001-02-26 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Nate Williams writes : >Again, memory overcommit is only *one* class of bugs that is avoided. >The phrase "can't see the forest for the trees" jumps to mind. :) Sure, and likewise, bugs in libc are only one *class* of bugs we can avoid, but that doesn't mean we don

Re: Setting memory allocators for library functions.

2001-02-26 Thread Nate Williams
> >Even in this case, there's no way to prove your code is not going to > >crash. > > Sure. But you can at least prove that all crashes are the result of bugs, > not merely design "features". 'Proving' something is correct is left as an excercise for the folks who have way too much time on thei

Re: Setting memory allocators for library functions.

2001-02-26 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Nate Williams writes : >Even in this case, there's no way to prove your code is not going to >crash. Sure. But you can at least prove that all crashes are the result of bugs, not merely design "features". From the point of view of proving that a system is designe

Re: Setting memory allocators for library functions.

2001-02-26 Thread Nate Williams
[ Memory overcommit ] > One important way to gain confidence that you're little box won't > silently crash at the worst possible time for the customer is to > be able to *prove* to yourself that it can't happen, given certain > assumptions. Those assumptions usually include things like "the > har

Re: Setting memory allocators for library functions.

2001-02-26 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Rik van Riel writes: >> No, I just disagree. It is useful for the OS to provide a hook for >> memory which is *known to work* - and that is the environment C specifies. >Send patches. I may some day. It's not very high on my priority list; I'd probably try to f

Re: Setting memory allocators for library functions.

2001-02-26 Thread Rik van Riel
On Sat, 24 Feb 2001, Peter Seebach wrote: > In message <9820.983050024@critter>, Poul-Henning Kamp writes: > >I think there is a language thing you don't understand here. > > No, I just disagree. It is useful for the OS to provide a hook for > memory which is *known to work* - and that is the env

Re: Setting memory allocators for library functions.

2001-02-26 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Matt Dillon writes: >The problem is a whole lot more complex then you think. Dealing with >overcommit is not simply counting mapped pages, there are all sorts >of issues involved. But the biggest gotcha is that putting in >overcommit protection wil

Re: Setting memory allocators for library functions.

2001-02-26 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Julian Elischer writes: >I still think that in such a case it should be possible to >'test the commitment' by touching all the allocated memory >while trapping page faults. And what do you do if you get one? There's no undo button for SIGSEGV. Traditionally, you

Re: Setting memory allocators for library functions.

2001-02-25 Thread Daniel C. Sobral
Matt Dillon wrote: > > But its all a crock. It simply isn't possible to gracefully handle > an out of memory condition. All sorts of side effects occur when > the system runs out of memory, even *with* overcommit protection. > In fact, all sorts of side effects occur even when t

Re: Setting memory allocators for library functions.

2001-02-25 Thread Matt Dillon
:In message <[EMAIL PROTECTED]>, "Daniel C. Sobral" writes: :>OTOH, the *only* way to get non-overcommit to FreeBSD is for someone who :>*wants* that feature to sit down and code it. It won't happen otherwise. : :So, out of idle curiousity: If, somewhere down the road, I know the kernel :well en

Re: Setting memory allocators for library functions.

2001-02-25 Thread Matt Dillon
:... :> : merging such a feature? :> :> Assuming that it doesn't break anything, that it doesn't introduce a :> severe performance penalty and works, there would be interest. There :> are times that this is a desirable feature. : :This thread reminds me of what happened when I brought up the sam

Re: Setting memory allocators for library functions.

2001-02-25 Thread Julian Elischer
Archie Cobbs wrote: > > Warner Losh writes: > > : >OTOH, the *only* way to get non-overcommit to FreeBSD is for someone who > > : >*wants* that feature to sit down and code it. It won't happen otherwise. > > : > > : So, out of idle curiousity: If, somewhere down the road, I know the kernel > > :

Re: Setting memory allocators for library functions.

2001-02-25 Thread Archie Cobbs
Warner Losh writes: > : >OTOH, the *only* way to get non-overcommit to FreeBSD is for someone who > : >*wants* that feature to sit down and code it. It won't happen otherwise. > : > : So, out of idle curiousity: If, somewhere down the road, I know the kernel > : well enough to attempt such a thi

Re: [hackers] Re: Setting memory allocators for library functions.

2001-02-25 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, David Gilbert write s: >IIRC, Digital-UNIX or OSF-1 ... or whatever it's called now. I seem >to remember the first Alphas that arrived to a company I worked for >had this set globally in the OS by default. Due to the bloat of the >OS and Motif and other such thing

Re: Setting memory allocators for library functions.

2001-02-25 Thread Warner Losh
In message <[EMAIL PROTECTED]> Peter Seebach writes: : In message <[EMAIL PROTECTED]>, "Daniel C. Sobral" writes: : >OTOH, the *only* way to get non-overcommit to FreeBSD is for someone who : >*wants* that feature to sit down and code it. It won't happen otherwise. : : So, out of idle curiousity:

Re: Setting memory allocators for library functions.

2001-02-25 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, "Daniel C. Sobral" writes: >OTOH, the *only* way to get non-overcommit to FreeBSD is for someone who >*wants* that feature to sit down and code it. It won't happen otherwise. So, out of idle curiousity: If, somewhere down the road, I know the kernel well enough to

Re: Setting memory allocators for library functions.

2001-02-25 Thread Dag-Erling Smorgrav
"Daniel C. Sobral" <[EMAIL PROTECTED]> writes: > It doesn't work. The application killed by reason of insufficient > resources is not (necessarily) the one that causes the page fault > leading to that. This is arguably a bug which needs to be fixed. DES -- Dag-Erling Smorgrav - [EMAIL PROTECTED

Re: Setting memory allocators for library functions.

2001-02-25 Thread Daniel C. Sobral
Julian Elischer wrote: > > to not be caught by surprise, > simply touch every page after you allocate it. It doesn't work. The application killed by reason of insufficient resources is not (necessarily) the one that causes the page fault leading to that. Id est, if my application allocates all

Re: Setting memory allocators for library functions.

2001-02-25 Thread Daniel C. Sobral
Dag-Erling Smorgrav wrote: > > > > None of these solutions are portable, however; > > Well, no, but the sole available definition of "portable" says that it is > > "portable" to assume that all the memory malloc can return is really > > available. > > Show me a modern OS (excluding real-time and

Re: Setting memory allocators for library functions.

2001-02-25 Thread Daniel C. Sobral
Dag-Erling Smorgrav wrote: > > [EMAIL PROTECTED] (Peter Seebach) writes: > > Is there any hope that, some day, a setting could be provided where a program > > could request that malloc *NOT* overcommit? There are programs which would > > rather know in advance, and clean up, than be killed abrup

Re: Setting memory allocators for library functions.

2001-02-25 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Warner Losh writes: >It says can, not must. But if it "can be used", and no one says "undefined behavior", then we're done; no undefined behavior is allowed. >I disagree with you that you can't overcommit. >Also, access is ill defined. It's defined better in C99

Re: Setting memory allocators for library functions.

2001-02-25 Thread Warner Losh
In message <[EMAIL PROTECTED]> Peter Seebach writes: : >I searched through the standard extensively to see if "allocates : >space" is defined and couldn't find anything other than 'the poitner : >can be used to access the space allocated.' : : EXACTLY! : : If it can't actually be used, then some

Re: Setting memory allocators for library functions.

2001-02-24 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Warner Losh writes: >I do not believe you. Such a "believe" does not appear to be embodied >in the C-99 standard. It's somewhat debated, but it has come up in discussions, and the consensus is that, if malloc returns a pointer, the memory has to be usable. >Notic

Re: Setting memory allocators for library functions.

2001-02-24 Thread Warner Losh
In message <[EMAIL PROTECTED]> Peter Seebach writes: : In message <9631.983048712@critter>, Poul-Henning Kamp writes: : >No it is not and it never was. : : The C committee believes it is. I do not believe you. Such a "believe" does not appear to be embodied in the C-99 standard. The standard (

Re: Setting memory allocators for library functions.

2001-02-24 Thread Julian Elischer
Peter Seebach wrote: > > In message <[EMAIL PROTECTED]>, Dag-Erling Smorgrav writes: > >This is all academic since FreeBSD does memory overcommit, so unless > >you run out of address space for your process before you run out of > >actual memory and/or swap (not likely, but quite possible) malloc(

Re: Setting memory allocators for library functions.

2001-02-24 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Dag-Erling Smorgrav writes: >It doesn't (and I'm very close to using expletives here). On the >contrary, it tries to always satisfy the application's requests and >hopes for the best. Yes, but it could provide a stronger guarantee than it does. >It's quite possibl

Re: Setting memory allocators for library functions.

2001-02-24 Thread Dag-Erling Smorgrav
[EMAIL PROTECTED] (Peter Seebach) writes: > In message <9877.983050267@critter>, Poul-Henning Kamp writes: > > And just how will the OS know that a particular memory chip will not > > generate an uncorrectable ECC error ? > It can't, but that's no reason for the OS to *add* reasons for failures.

Re: Setting memory allocators for library functions.

2001-02-24 Thread Peter Seebach
In message <9877.983050267@critter>, Poul-Henning Kamp writes: >And just how will the OS know that a particular memory chip will not >generate an uncorrectable ECC error ? It can't, but that's no reason for the OS to *add* reasons for failures. -s To Unsubscribe: send mail to [EMAIL PROTECTED]

Re: Setting memory allocators for library functions.

2001-02-24 Thread Poul-Henning Kamp
In message <[EMAIL PROTECTED]>, Peter Seebach writes : >In message <9820.983050024@critter>, Poul-Henning Kamp writes: >>I think there is a language thing you don't understand here. > >No, I just disagree. It is useful for the OS to provide a hook for >memory which is *known to work* - and that i

Re: Setting memory allocators for library functions.

2001-02-24 Thread Peter Seebach
In message <9820.983050024@critter>, Poul-Henning Kamp writes: >I think there is a language thing you don't understand here. No, I just disagree. It is useful for the OS to provide a hook for memory which is *known to work* - and that is the environment C specifies. -s To Unsubscribe: send mai

Re: Setting memory allocators for library functions.

2001-02-24 Thread Poul-Henning Kamp
In message <[EMAIL PROTECTED]>, Peter Seebach writes : >In message <9631.983048712@critter>, Poul-Henning Kamp writes: >>No it is not and it never was. > >The C committee believes it is. The C committee doesn't deal with operating systems or the real world for that matter. They only interest the

Re: Setting memory allocators for library functions.

2001-02-24 Thread Peter Seebach
In message <9631.983048712@critter>, Poul-Henning Kamp writes: >No it is not and it never was. The C committee believes it is. -s To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message

Re: Setting memory allocators for library functions.

2001-02-24 Thread Poul-Henning Kamp
In message <[EMAIL PROTECTED]>, Peter Seebach writes : >In message <9469.983047707@critter>, Poul-Henning Kamp writes: >>The guarantee is "If malloc returns NULL there is no memory you can use". > >No, it's "if the memory is not available, malloc returns NULL". No it is not and it never was. See

Re: Setting memory allocators for library functions.

2001-02-24 Thread Greg Black
Poul-Henning Kamp wrote: > In message <[EMAIL PROTECTED]>, Peter Seebach writes > : > >In message <9402.983047348@critter>, Poul-Henning Kamp writes: > >>>Well, no, but the sole available definition of "portable" says that it is > >>>"portable" to assume that all the memory malloc can return is r

Re: Setting memory allocators for library functions.

2001-02-24 Thread Peter Seebach
In message <9469.983047707@critter>, Poul-Henning Kamp writes: >The guarantee is "If malloc returns NULL there is no memory you can use". No, it's "if the memory is not available, malloc returns NULL". >That doesn't mean that just because != NULL is returned that memory >will in fact be availabl

Re: Setting memory allocators for library functions.

2001-02-24 Thread Poul-Henning Kamp
In message <[EMAIL PROTECTED]>, Peter Seebach writes : >In message <9402.983047348@critter>, Poul-Henning Kamp writes: >>>Well, no, but the sole available definition of "portable" says that it is >>>"portable" to assume that all the memory malloc can return is really >>>available. > >>No, this is

Re: Setting memory allocators for library functions.

2001-02-24 Thread Peter Seebach
In message <9402.983047348@critter>, Poul-Henning Kamp writes: >>Well, no, but the sole available definition of "portable" says that it is >>"portable" to assume that all the memory malloc can return is really >>available. >No, this is not a guarantee. Yes, it is. If the memory isn't available,

Re: Setting memory allocators for library functions.

2001-02-24 Thread Dag-Erling Smorgrav
[EMAIL PROTECTED] (Peter Seebach) writes: > In message <[EMAIL PROTECTED]>, Dag-Erling Smorgrav writes: > >Malloc() does not overcommit - the kernel does. Malloc() doesn't know > >and doesn't care. > But it could still probably force the behavior. Barring kernel changes, not easily, and only for

Re: Setting memory allocators for library functions.

2001-02-24 Thread Poul-Henning Kamp
In message <[EMAIL PROTECTED]>, Peter Seebach writes : >In message <[EMAIL PROTECTED]>, Dag-Erling Smorgrav writes: >>Malloc() does not overcommit - the kernel does. Malloc() doesn't know >>and doesn't care. > >But it could still probably force the behavior. > >>None of these solutions are portabl

Re: Setting memory allocators for library functions.

2001-02-24 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Dag-Erling Smorgrav writes: >Malloc() does not overcommit - the kernel does. Malloc() doesn't know >and doesn't care. But it could still probably force the behavior. >None of these solutions are portable, however; Well, no, but the sole available definition of "p

Re: Setting memory allocators for library functions.

2001-02-24 Thread Dag-Erling Smorgrav
Dag-Erling Smorgrav <[EMAIL PROTECTED]> writes: > if (sigsetjmp(env) == -1) { Blah, this should be if (sigsetjmp(env, 1) == -1) { DES -- Dag-Erling Smorgrav - [EMAIL PROTECTED] To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message

Re: Setting memory allocators for library functions.

2001-02-24 Thread Dag-Erling Smorgrav
[EMAIL PROTECTED] (Peter Seebach) writes: > Is there any hope that, some day, a setting could be provided where a program > could request that malloc *NOT* overcommit? There are programs which would > rather know in advance, and clean up, than be killed abruptly. Malloc() does not overcommit - t

Re: Setting memory allocators for library functions.

2001-02-24 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Dag-Erling Smorgrav writes: >This is all academic since FreeBSD does memory overcommit, so unless >you run out of address space for your process before you run out of >actual memory and/or swap (not likely, but quite possible) malloc() >will never return NULL and yo

Re: Setting memory allocators for library functions.

2001-02-24 Thread Dag-Erling Smorgrav
[EMAIL PROTECTED] (Peter Seebach) writes: > In message <[EMAIL PROTECTED]>, Farooq Mela writes: > > How do you guys feel about this? > It is a mistake to believe that you "don't have to worry about running > out of memory". You should always check, every time, and exit as gracefully > as you can.

Re: Setting memory allocators for library functions.

2001-02-23 Thread Thomas David Rivers
Farooq Mela <[EMAIL PROTECTED]> wrote: > > Hi, > > Usually when I write programs, I have functions such as the following: > > void * > xmalloc(size_t size) > { > > } > > void * > xrealloc(void *ptr, size_t size) > { > > } > > And then I use these instead of malloc and realloc t

Re: Setting memory allocators for library functions.

2001-02-23 Thread Alfred Perlstein
* Farooq Mela <[EMAIL PROTECTED]> [010223 00:22] wrote: > Alfred Perlstein wrote: > > > > * Farooq Mela <[EMAIL PROTECTED]> [010222 23:52] wrote: > > > > > > This is not what I am arguing. I gave a simple example of an xmalloc > > > function which does just print an error and exit. However, I've

Re: Setting memory allocators for library functions.

2001-02-23 Thread Farooq Mela
Alfred Perlstein wrote: > > * Farooq Mela <[EMAIL PROTECTED]> [010222 23:52] wrote: > > > > This is not what I am arguing. I gave a simple example of an xmalloc > > function which does just print an error and exit. However, I've written > > many large applications using this sort of scheme where

Re: Setting memory allocators for library functions.

2001-02-23 Thread Alfred Perlstein
* Farooq Mela <[EMAIL PROTECTED]> [010222 23:52] wrote: > > This is not what I am arguing. I gave a simple example of an xmalloc > function which does just print an error and exit. However, I've written > many large applications using this sort of scheme where when allocation > fails, all sorts o

Re: Setting memory allocators for library functions.

2001-02-22 Thread Farooq Mela
Peter Seebach wrote: > > In message <[EMAIL PROTECTED]>, Farooq Mela writes: > >Of course I realize that allocating memory can fail. That is why I use > >xmalloc and friends - so that I can avoid having to check for failure > >each time I want to allocate memory. > > That's the problem. You sti

Re: Setting memory allocators for library functions.

2001-02-22 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Farooq Mela writes: >Of course I realize that allocating memory can fail. That is why I use >xmalloc and friends - so that I can avoid having to check for failure >each time I want to allocate memory. That's the problem. You still *NEED* to check. You can't just

Re: Setting memory allocators for library functions.

2001-02-22 Thread Farooq Mela
Peter Seebach wrote: > It is a mistake to believe that you "don't have to worry about running > out of memory". You should always check, every time, and exit as gracefully > as you can. > > -s Of course I realize that allocating memory can fail. That is why I use xmalloc and friends - so that

Re: Setting memory allocators for library functions.

2001-02-22 Thread Peter Seebach
In message <[EMAIL PROTECTED]>, Farooq Mela writes: >How do you guys feel about this? It is a mistake to believe that you "don't have to worry about running out of memory". You should always check, every time, and exit as gracefully as you can. -s To Unsubscribe: send mail to [EMAIL PROTECTED]

Setting memory allocators for library functions.

2001-02-22 Thread Farooq Mela
Hi, Usually when I write programs, I have functions such as the following: void * xmalloc(size_t size) { void *p; if ((p=malloc(size))==NULL) { fprintf(stderr, "out of memory\n"); exit(1); } return(p); } void * xrealloc(void *ptr,