Sujet : Re: realloc() - frequency, conditions, or experiences about relocation?
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.lang.cDate : 17. Jun 2024, 13:15:11
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v4p9cg$lbo4$1@dont-email.me>
References : 1
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
On 17/06/2024 08:08, Janis Papanagnou wrote:
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
Consider your target audience and their hardware, the target OS, and the realistic size of your data. If the target is a PC, you can happily malloc tens of MB at the start without a care, and for systems that do not actually allocate system memory until you try to access the area, there is no cost to this.
So in many situations where you are reading and parsing data from a file, you can just do the initial malloc with more than enough space for any realistic input file. You might still implement a realloc solution for occasional extreme uses, and because it is nice to avoid artificial limits for programs, but efficiency matters a lot less in those cases.
It may also be the case that even if realloc returns a different address and logically copies a lot of data, that this is done by smarter virtual memory mapping so that only the mapping changes, and the underlying physical ram does not need to be copied. But I don't know if OS's and realloc implementations are smart enough to do that.
Date | Sujet | # | | Auteur |
17 Jun 24 | realloc() - frequency, conditions, or experiences about relocation? | 95 | | Janis Papanagnou |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Chris M. Thomasson |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 53 | | Ben Bacarisse |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 52 | | Malcolm McLean |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 50 | | Ben Bacarisse |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 49 | | Malcolm McLean |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 21 | | Ben Bacarisse |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 17 | | Anton Shepelev |
18 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 16 | | Tim Rentsch |
18 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 8 | | Malcolm McLean |
18 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 5 | | Malcolm McLean |
29 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 4 | | Lawrence D'Oliveiro |
2 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 3 | | Malcolm McLean |
2 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Ben Bacarisse |
4 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Lawrence D'Oliveiro |
24 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 2 | | Tim Rentsch |
24 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | David Brown |
20 Jun 24 | Indefinite pronouns [was:Re: realloc() - frequency, conditions, or experiences about relocation?] | 7 | | Anton Shepelev |
20 Jun 24 | Re: Indefinite pronouns | 3 | | vallor |
21 Jun 24 | Re: Indefinite pronouns | 2 | | David Brown |
21 Jun 24 | Re: Indefinite pronouns | 1 | | Keith Thompson |
20 Jun 24 | Re: Indefinite pronouns [was:Re: realloc() - frequency, conditions, or experiences about relocation?] | 2 | | Kenny McCormack |
20 Jun 24 | Re: Indefinite pronouns [was: Re: <something technical>] | 1 | | Janis Papanagnou |
21 Jun 24 | Re: Indefinite pronouns [was:Re: realloc() - frequency, conditions, or experiences about relocation?] | 1 | | Tim Rentsch |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 2 | | Richard Harnden |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Chris M. Thomasson |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Malcolm McLean |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 23 | | Anton Shepelev |
18 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | David Jones |
19 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 9 | | David Duffy |
19 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 7 | | Malcolm McLean |
19 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 4 | | Ben Bacarisse |
19 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 3 | | David Brown |
19 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 2 | | Ben Bacarisse |
20 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | David Brown |
20 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 2 | | Anton Shepelev |
8 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Anton Shepelev |
19 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Anton Shepelev |
2 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 12 | | Rich Ulrich |
2 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 5 | | Keith Thompson |
2 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 4 | | Rich Ulrich |
8 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 3 | | Anton Shepelev |
22 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 2 | | Rich Ulrich |
23 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Anton Shepelev |
2 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 6 | | Paul |
2 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 5 | | Rich Ulrich |
2 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 4 | | Rich Ulrich |
2 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 3 | | Paul |
2 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | James Kuyper |
2 Jul 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | James Kuyper |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Chris M. Thomasson |
18 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 3 | | Keith Thompson |
18 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Malcolm McLean |
18 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Bonita Montero |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | David Brown |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 28 | | Bonita Montero |
20 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 27 | | Vir Campestris |
21 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 26 | | Bonita Montero |
24 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 25 | | Lawrence D'Oliveiro |
24 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 21 | | Keith Thompson |
24 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 11 | | David Brown |
24 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 7 | | Malcolm McLean |
24 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 3 | | Keith Thompson |
25 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Malcolm McLean |
25 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Chris M. Thomasson |
25 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 3 | | Lawrence D'Oliveiro |
25 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 2 | | Bonita Montero |
26 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Lawrence D'Oliveiro |
24 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 2 | | Chris M. Thomasson |
24 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Bonita Montero |
25 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Lawrence D'Oliveiro |
24 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Bonita Montero |
25 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 8 | | Lawrence D'Oliveiro |
25 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 6 | | Keith Thompson |
25 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Richard Damon |
28 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 2 | | Phil Carmody |
28 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Keith Thompson |
28 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 2 | | James Kuyper |
28 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Keith Thompson |
28 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | James Kuyper |
24 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 3 | | Bonita Montero |
24 Jun 24 | Down the hall, past the water cooler, third door on the left... (Was: realloc() - frequency, conditions, or experiences about) relocation? | 2 | | Kenny McCormack |
24 Jun 24 | Re: Down the hall, past the water cooler, third door on the left... (Was: realloc() - frequency, conditions, or experiences about) relocation? | 1 | | Bonita Montero |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 2 | | David Brown |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Bonita Montero |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Janis Papanagnou |
17 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Michael S |
18 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Rosario19 |
25 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 7 | | Bonita Montero |
25 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 4 | | Vir Campestris |
25 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 3 | | Bonita Montero |
26 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 2 | | Vir Campestris |
26 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Bonita Montero |
25 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 2 | | DFS |
25 Jun 24 | Re: realloc() - frequency, conditions, or experiences about relocation? | 1 | | Bonita Montero |