In the current version of redis,Sds_max_preallocIs1024*1024, That is, when the size is smaller1 MBWhen the append operation is performed,SdsmakeroomforAllocate more space than the required size. When the string size is greater1 MB, ThenSdsmakeroomforThey are allocated more1 MB.
ExecutedAppendThe command string carries additional pre-allocated space, which will not be released unless the key corresponding to the string is deleted, or after redis is disabled, no pre-allocated space will be allocated to the re-loaded string objects during restart.
Because executionAppendThe number of string keys in a command is usually not large, and the memory size is usually small. Therefore, this is generally not a problem.
On the other hand, ifAppendThere are many keys to operate, and if the string size is large, you may need to modify the redis server so that it can regularly release pre-allocated space for some string keys, so as to use the memory more effectively.
SDS (Simple Dynamic string) memory pre-allocation optimization strategy