ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
[TOC] ``` typedef struct redisObject { // 类型 unsigned type:4; // 编码 unsigned encoding:4; // 对象最后一次被访问的时间 unsigned lru:REDIS_LRU_BITS; /* lru time (relative to server.lruclock) */ // 引用计数 int refcount; // 指向实际值的指针 void *ptr; } robj; ``` 好奇 unsigned 变量名:4,占用多少字节,整个redisObject占用多少字节 参考:https://www.cnblogs.com/Jacket-K/p/8365384.html http://blog.chinaunix.net/uid-20726927-id-2455478.html 得出结论:unsigned type:4 ,是一个占用4位的位域,sizeof(struct robj) 在64位系统,是 4+4+24+32+64 = 128位 = 16字节