Skip to content

Commit

Permalink
core: test: Increase linearly for realloc size
Browse files Browse the repository at this point in the history
When using exponentially resizing, we met the following exploded using
memory resources:

```
cycle  1: 4096
cycle  2: 8192
cycle  3: 16384
cycle  4: 32768
cycle  5: 65536
cycle  6: 131072
cycle  7: 262144
cycle  8: 524288
cycle  9: 1048576
cycle 10: 2097152
cycle 11: 4194304
cycle 12: 8388608
cycle 13: 16777216
cycle 14: 33554432
cycle 15: 67108864
cycle 16: 134217728
cycle 17: 268435456
cycle 18: 536870912
cycle 19: 1073741824
cycle 20: 2147483648
```

This shouldn't be suitable for the most cases. To reduce the allocation,
we need to increase linearly for adjusting of allocating memory.

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Jul 20, 2023
1 parent 78d88f5 commit b3e3a58
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/config_format/flb_cf_fluentbit.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ static int read_config(struct flb_cf *cf, struct local_ctx *ctx,
#ifndef FLB_HAVE_STATIC_CONF
else {
/* resize the line buffer */
bufsize *= 2;
bufsize += FLB_DEFAULT_CF_BUF_SIZE;
buf = flb_realloc(buf, bufsize);
if (!buf) {
flb_error("failed to resize line buffer to %zu", bufsize);
Expand Down

0 comments on commit b3e3a58

Please sign in to comment.