diff options
author | antirez <antirez@gmail.com> | 2012-08-24 12:55:37 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2012-08-24 12:55:37 +0200 |
commit | 6fdc635447b1a5dd0a4f7b13c15fdd6c108dabee (patch) | |
tree | b8db5f26496115d56fc4e05fee0b3c20a38919c8 /src/zmalloc.h | |
parent | 850789ce73dbb236591692708437e1bd705dbce3 (diff) | |
download | redis-6fdc635447b1a5dd0a4f7b13c15fdd6c108dabee.tar.gz |
Better Out of Memory handling.
The previous implementation of zmalloc.c was not able to handle out of
memory in an application-specific way. It just logged an error on
standard error, and aborted.
The result was that in the case of an actual out of memory in Redis
where malloc returned NULL (In Linux this actually happens under
specific overcommit policy settings and/or with no or little swap
configured) the error was not properly logged in the Redis log.
This commit fixes this problem, fixing issue #509.
Now the out of memory is properly reported in the Redis log and a stack
trace is generated.
The approach used is to provide a configurable out of memory handler
to zmalloc (otherwise the default one logging the event on the
standard output is used).
Diffstat (limited to 'src/zmalloc.h')
-rw-r--r-- | src/zmalloc.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/zmalloc.h b/src/zmalloc.h index 89f5b6ee0..14e79534e 100644 --- a/src/zmalloc.h +++ b/src/zmalloc.h @@ -72,6 +72,7 @@ void zfree(void *ptr); char *zstrdup(const char *s); size_t zmalloc_used_memory(void); void zmalloc_enable_thread_safeness(void); +void zmalloc_set_oom_handler(void (*oom_handler)(size_t)); float zmalloc_get_fragmentation_ratio(void); size_t zmalloc_get_rss(void); void zlibc_free(void *ptr); |