Hi!guys.I am a beginner, and after learning about object sharing, I learned that Integer objects can be shared and REFCOUNT +1 every time they are shared, but when I experimented with it, I found that this is not fits with what I understand. Is this a bug or has the current version changed?

Comment From: enjoy-binbin

the 0-9999 is shared by default and only. it is not a bug.

so in your first img, the 10000 will not be shared, so each of them is a single robj.

in the second img, the 9999 is shared, so it's refcount is a fixed MAX number, so it won't ++. (we now use a fixed MAX number to identify that it is a shared number)

in the third img (the book one), it is a old version (i belive it is a Redis 3.0 version book) and the shared logic have been changed.

Comment From: ddddjc

the 0-9999 is shared by default and only. it is not a bug.

so in your first img, the 10000 will not be shared, so each of them is a single robj.

in the second img, the 9999 is shared, so it's refcount is a fixed MAX number, so it won't ++. (we now use a fixed MAX number to identify that it is a shared number)

in the third img (the book one), it is a old version (i belive it is a Redis 3.0 version book) and the shared logic have been changed.

think you!