Why redis need zmalloc?

1,324 views
Skip to first unread message

wenhao wen

unread,
Mar 4, 2012, 10:22:09 AM3/4/12
to Redis DB
Hi, everyone.
I am reading the source code of redis, and wondering why redis replace
malloc with zmalloc.
What's the usage of the header of the memory?
Thank you so much

Salvatore Sanfilippo

unread,
Mar 4, 2012, 10:26:10 AM3/4/12
to redi...@googlegroups.com
Hello, there is no other way to have a real-time and precise metrics
of the allocated memory otherwise.

Thanks to zmalloc Redis can implement maxmemory easily, you can do
something like:

while (used_memory() > configured_max_memory) {
evict_smoe_object();
}

There are no other ways to do this, there is even a lack of
platform-specific non portable ways.

Cheers,
Salvatore

> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
>

--
Salvatore 'antirez' Sanfilippo
open source developer - VMware

http://invece.org
"We are what we repeatedly do. Excellence, therefore, is not an act,
but a habit." -- Aristotele

redis.f...@gmail.com

unread,
Dec 1, 2016, 11:43:16 AM12/1/16
to Redis DB
Hello Salvatore,

I was wondering what exactly did mean by "real-time and precise".
Isn't /proc/self/status real-time and precise (assuming I don't care about portability)?

If that is really the case, could you please explain why? How can I verify it?

Best regards,
Reply all
Reply to author
Forward
0 new messages