Prev: Blanking the video display programmatically.
Next: Overlapped IO Fail with Error 995 i.e. ERROR_OPERATION_ABORTED
From: Jonathan de Boyne Pollard on 20 Mar 2010 03:59 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> <blockquote cite="mid:87zl29wdxz.fsf(a)fever.mssgmbh.com" type="cite"> <blockquote type="cite"> <p wrap="">However, I wouldn't want all the dozens of apps on my desktop to all refuse to return memory back to the system just because they might want it again at some point in the future (thus unnecessarily forcing swapping to disk or a memory upgrade). Unless there is a very specific reason to think that performance is critical, my personal view is that it's polite for a userspace app to return memory back to the underlying system whenever it is reasonably possible.<br> </p> </blockquote> <p wrap=""><code>malloc</code> may or may not return memory to the system. Usually, it won't, except in fringe cases (eg 'large allocations' done via <code>mmap</code>). Memory allocations which originally happened by calling <code>brk</code>/<code>sbrk</code> cannot easily be returned to the system, anyway, only if freeing them happens to release a chunk of memory just below the current break.<br> </p> </blockquote> <p>On the contrary, usually it will. I'm revising my estimate of the quality of your "50 — 300 lines of code" implementation downwards as a result of this statement, because you are erroneously conflating allocating address space with committing pages. Most implementations that I am familiar with were written by people that didn't make this mistake. <br> </p> <p>My implementation (more correctly, one of my implementations (-:) calls the OS/2 <code>DosSetMem()</code> function to commit partially used pages and de-commit wholly unused pages within the heap arena as necessary. Several Win32 implementations that I'm aware of call <code>VirtualAlloc()</code> to commit and de-commit pages within arenas. (For a good explanation of this process, see Matt Pietrek's dissection of the DOS-Windows 9x <code>HeapAlloc()</code> function in his <i>Windows 95 System Programming Secrets</i> book.) The GNU C library version 2.11.1 calls <code>madvise()</code> with the <code>MADV_DONTNEED</code> flag for wholly unused pages. <br> </p> <p>The OS/2 and Win32 implementations are returning unused heap memory to the operating system as a matter of course. The GNU C library is intending to do the same, and is doing the best that it can with the more limited system API that it has to work with, and the operating system bugs that it has to cope with. (See, for example, <a href="http://bugzilla.kernel.org./show_bug.cgi?id=6282">Linux kernel bug #6282</a>, reported by Samuel Thibault in 2007.)<br> </p> </body> </html>
From: Ian Collins on 20 Mar 2010 04:27 On 03/20/10 08:59 PM, Jonathan de Boyne Pollard wrote: Please stop cross-posting to so many groups and worse still, snipping attributions. -- Ian Collins
From: Richard Bos on 20 Mar 2010 15:05 Ian Collins <ian-news(a)hotmail.com> wrote: > On 03/20/10 08:59 PM, Jonathan de Boyne Pollard wrote: > > Please stop cross-posting to so many groups and worse still, snipping > attributions. Not to mention posting bloody HTML, in the raw. If you _must_ post HTML, use the proper headers so that my server can dump it in the bit-bucket in non-binary groups, as it should. Richard
From: Rainer Weikusat on 21 Mar 2010 15:10 Jonathan de Boyne Pollard <J.deBoynePollard-newsgroups(a)NTLWorld.COM> writes: > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> In addition to the useless crosspost, the HTML is also unkind. I was actually seriously trying to edit this into a readable text in order to address your somewhat 'weird' statements about malloc implementations not written by yourself but quickly grew tired of the effort. Feel free to repost this in human-readable form and with a selection of 'newsgroups' that lets you look less like a troll.
From: Scott Lurndal on 21 Mar 2010 21:33
Ian Collins <ian-news(a)hotmail.com> writes: >On 03/20/10 08:59 PM, Jonathan de Boyne Pollard wrote: > >Please stop cross-posting to so many groups and worse still, snipping >attributions. > And even worse still, posting in HTML. |