Deutsch English Français Italiano |
<v4ov8h$j2q2$1@raubtier-asyl.eternal-september.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail From: Bonita Montero <Bonita.Montero@gmail.com> Newsgroups: comp.lang.c Subject: Re: realloc() - frequency, conditions, or experiences about relocation? Date: Mon, 17 Jun 2024 11:22:31 +0200 Organization: A noiseless patient Spider Lines: 23 Message-ID: <v4ov8h$j2q2$1@raubtier-asyl.eternal-september.org> References: <v4ojs8$gvji$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 17 Jun 2024 11:22:26 +0200 (CEST) Injection-Info: raubtier-asyl.eternal-september.org; posting-host="567fea0737ace9203b0a3bd3650a3401"; logging-data="625474"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8BNSnwWyKIgP5ybK0Se6a+z2dTCi3hSQ=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:Re76+ouRepIyq7HdnyD+uvJlRqE= Content-Language: de-DE In-Reply-To: <v4ojs8$gvji$1@dont-email.me> Bytes: 2364 Am 17.06.2024 um 08:08 schrieb Janis Papanagnou: > In a recent thread realloc() was a substantial part of the discussion. > "Occasionally" the increased data storage will be relocated along > with the previously stored data. On huge data sets that might be a > performance factor. Is there any experience or are there any concrete > factors about the conditions when this relocation happens? - I could > imagine that it's no issue as long as you're in some kB buffer range, > but if, say, we're using realloc() to substantially increase buffers > often it might be an issue to consider. It would be good to get some > feeling about that internal. > > Janis realloc() is just a convenience funciton. Usually the reallocation can't happen in-place and a second malloc() followed by a copy and a free() does the same. For large data it would be nice if the pages being deallocated later would be incrementally marked as discardable after copying a portion. This would result in only a small portion of additional physical memory being allocated since the newly allocated pages become asso- ciated with phyiscal pages when they're touched first. Windows has VirtualAlloc() with MEM_RESET for that, Linux has madvise() with MADV_DONTNEED.