Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions rdbtools/memprofiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,13 @@ def sizeof_string(self, string):
# https://github.com/antirez/redis/blob/unstable/src/sds.h
try:
num = int(string)
if num < REDIS_SHARED_INTEGERS :
tmp_str = str(num)
long_max = (1 << (self._architecture - 1)) - 1

# if string like '0****' or '-0***', should calculate malloc_overhead
# if num is between long_min and long_max,the integer is part of the robj, no extra memory
if string == tmp_str and -long_max - 1 <= num <= long_max:
return 0
else :
return 0 # the integer is part of the robj, no extra memory
except ValueError:
pass
l = len(string)
Expand Down