<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[MCCreeper的博客]]></title><description><![CDATA[一般是自用笔记]]></description><link>https://blog.youkuaiyun.com/MCCreeper</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; MCCreeper]]></copyright><item><title><![CDATA[Redis为什么要用单线程？]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/149813157</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/149813157</guid><author>MCCreeper</author><pubDate>Thu, 31 Jul 2025 20:51:17 +0800</pubDate><description><![CDATA[主要是因为cpu和内存之间虽然速度差距也不小，但上下文切换本身也是很大程度基于内存的，而且和redis的命令比起来更加复杂，也就是说上下文切换的事件比命令的执行时间长，多线程是由于io或其他耗时任务阻塞，cpu空置所以需要cpu消耗一定时间去切换上下文（包括切出去和切回来）以获取（空置时间-上下文切换时间）长度的时间去进行一些别的操作，如果空置时间（redis命令执行）已经小于上下文切换时间了，那其实是省不出cpu时间的。]]></description><category></category></item><item><title><![CDATA[C++ 多态Clone方法的模板化实现方式笔记]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/137303527</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/137303527</guid><author>MCCreeper</author><pubDate>Wed, 03 Apr 2024 00:39:49 +0800</pubDate><description><![CDATA[C++多态克隆（clone）方法的模板化实现，运用CRTP (Curiously Recurring Template Pattern)方法]]></description><category></category></item><item><title><![CDATA[总结一下shared_from_this的使用注意事项]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/137048866</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/137048866</guid><author>MCCreeper</author><pubDate>Tue, 26 Mar 2024 16:26:01 +0800</pubDate><description><![CDATA[在这个例子中，使用指向子类实例的父类指针去创建shared_ptr时，shared_ptr()不知道这个父类指针指向的对象实际上继承了enable_shared_from_this，也就没有做相应的赋值，shared_from_this()会产生报错。先创建子类的shared_ptr后再转换为父类的shared_ptr就能避免报错。]]></description><category></category></item><item><title><![CDATA[关于C++多层虚继承时构造函数初始化时的特性]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/136578831</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/136578831</guid><author>MCCreeper</author><pubDate>Sat, 09 Mar 2024 11:06:40 +0800</pubDate><description><![CDATA[C++的派生类在构造过程中选择**虚继承**基类的构造函数时，只会按照当前派生类选择的方式调用基类构造函数，而其基类定义的要调用哪个构造函数，以及如何调用都被忽略了。]]></description><category></category></item><item><title><![CDATA[关于cin+cout与scanf+printf两套输入输出函数的不同]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/129498230</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/129498230</guid><author>MCCreeper</author><pubDate>Mon, 13 Mar 2023 17:33:50 +0800</pubDate><description><![CDATA[这两套函数在对字符串的处理上也有不同的逻辑。另外，需要注意string.resize会将数据区中的resize大小往后的数据填入’\0’，在试验时影响到了测试结果。性能上就先不提了，很多文章都是在说明scanf+printf比cin+cout高效。]]></description><category></category></item><item><title><![CDATA[关于完美转发中forward的作用的一点理解]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/129145074</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/129145074</guid><author>MCCreeper</author><pubDate>Tue, 21 Feb 2023 17:06:32 +0800</pubDate><description><![CDATA[forward能够将右值引用和左值引用（均为lvalue）区分出来(利用引用折叠的机制)，然后相应地调用static_cast()转换为lvalue，或static_cast()转换为rvalue。在pass(1)的情况下，pass(T&& v)被实例化为pass(int&& v)，在pass函数内用这个右值引用（类型为左值）只能调用到reference(int& v)，右值引用本身是一个左值。当存在fn(X &);rvalue(right value)右值：有无标识符皆可，可以被回收。]]></description><category></category></item><item><title><![CDATA[关于OpenGL纹理尺寸的坑 - 图像行偏移，出现异色条纹]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/128695194</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/128695194</guid><author>MCCreeper</author><pubDate>Sun, 15 Jan 2023 16:21:56 +0800</pubDate><description><![CDATA[OpenGL纹理行出现偏移，或者各行颜色失真，有一定周期性可能的原因。]]></description><category></category></item><item><title><![CDATA[关于滑动窗口协议为什么发送窗口与接收窗口之和要小于或等于2^n]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/127938205</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/127938205</guid><author>MCCreeper</author><pubDate>Sat, 19 Nov 2022 16:39:27 +0800</pubDate><description><![CDATA[发送窗口与接收窗口之和小于2^n主要就是为了防止这种情况的发生：接收方的ACK总是丢失，进而导致发送窗口不动，而接收窗口不断接收数据被“挤”到发送窗口之后（接收窗口会一直运动直到接收窗口的开头正好再发送窗口的尾部之后），如果发送窗口与接收窗口之和的长度大于2^n，将序号空间考虑为一个环，发送窗口与接收窗口连接起来后会“套圈”，导致发送窗口在不断发送的“老帧”能落在发送窗口不断移动后出现的同序号的“新帧”槽位中。只要避免这种“套圈”现象，也即发送窗口与接收窗口之和小于或等于2^n即可。]]></description><category></category></item><item><title><![CDATA[关于ffmpeg库 使用av_frame_free之类操作后内存不会减少的现象]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/124766871</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/124766871</guid><author>MCCreeper</author><pubDate>Sat, 14 May 2022 13:12:09 +0800</pubDate><description><![CDATA[出现的问题:
最近使用ffmpeg+qt制作音视频播放器的解码模块时出现了内存占用过高的情况,想通过av_frame_free等操作减少内存内存占用，但内存上涨之后调用这类操作内存占用并不会减少.
原因:
内存占用没减少的原因并不是因为av_frame_free操作未生效，实际上，如果不调用free指令，内存是会不断上升的，调用清理内存的指令的话内存在上涨到一定程度时就不会上涨了.
因为ffmpeg内部分配内存和清理内存时采用了 “缓存池” 的机制，内存不够时会增加池的大小，而调用者欲释放内存时，池并不会立]]></description><category></category></item><item><title><![CDATA[关于Unity AsyncOperation.allwoSceneActivation不生效的问题]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/123901763</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/123901763</guid><author>MCCreeper</author><pubDate>Fri, 01 Apr 2022 16:46:24 +0800</pubDate><description><![CDATA[Unity版本2020.3
官方文档中提到:

You should set and use AsyncOperation.allowSceneActivation in
coroutine functions. You cannot set and use
AsyncOperation.allowSceneActivation within Awake, because this
function is not a coroutine.

不能在Awake中使用allowSceneActivation,且]]></description><category></category></item><item><title><![CDATA[关于透视投影得到的深度为什么是非线性的]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/123799449</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/123799449</guid><author>MCCreeper</author><pubDate>Mon, 28 Mar 2022 17:29:38 +0800</pubDate><description><![CDATA[透视投影会将坐标由观察空间投影到NDC空间中，而其中的x,y坐标比较简单，通过相似三角形的原理，将坐标投影到近平面，得到的二维坐标再经过一点线性变换就是NDC坐标的前两个分量.
如下图，p’在近平面np上可以得到一个二维坐标.

经过变换后我们得到了NDC坐标中的x和y分量,记为Xn和Yn，这个二维坐标与观察空间中的z坐标Ze有关,且是跟1/Ze有关，而且我们需要单纯通过矩阵乘法从观察空间转换到NDC空间中，显然只靠乘法是无法表达出1/Ze的，还需要在乘以投影矩阵后在进行透视除法，所有的分量都除以w，使得w]]></description><category></category></item><item><title><![CDATA[C++获取动态数组的长度的一个方法]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/123595064</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/123595064</guid><author>MCCreeper</author><pubDate>Sat, 19 Mar 2022 14:54:38 +0800</pubDate><description><![CDATA[因为这个方法不在标准库中，所以用的人比较少，网上提及的也少.
用_msize(pointer)/sizeof(type)可以得到动态数组的长度.

]]></description><category></category></item><item><title><![CDATA[opengl使用VAO和VBO绘制三角形时glVertexAttribPointer的调用位置不正确产生的小问题]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/122118924</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/122118924</guid><author>MCCreeper</author><pubDate>Thu, 23 Dec 2021 23:51:02 +0800</pubDate><description><![CDATA[绘制三角形指定顶点指针时调用了glVertexAttribPointer,glVertexAttribPointer应该是根据glBindBuffer指定的buffer ID得到一个vertex的起始地址，再依据这个地址查找数据进行绘制.
因此，如果不先分配一个buffer且调用glBindBuffer，就调用glVertexAttribPointer的话，在opengl状态机中保存的vertex的起始地址就会是一个空指针（出错）,从而导致画不出东西.

...]]></description><category></category></item><item><title><![CDATA[springboot validation使用笔记]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/121066450</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/121066450</guid><author>MCCreeper</author><pubDate>Sun, 31 Oct 2021 17:18:21 +0800</pubDate><description><![CDATA[这两天研究validation的用法，先入为主地认为validation可以对数据类型的setter方法进行限制，在使用后发现validation的功能其实比较有限，一般只在以下情况才会起作用，其他情况下只能亲自使用工厂类生成的validator进行验证。
以下两种情况下被标记的数据会检测数据是否符合要求，不符合时会抛出异常：

Pojo 上加检查规则, Controller 视图函数Pojo形参前加上 @Validated 来触发检查动作.
在 bean 类(Service 类，Repository类均可]]></description><category></category></item><item><title><![CDATA[java Calendar set方法得到的结果不对，一个小坑记录一下]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/121062933</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/121062933</guid><author>MCCreeper</author><pubDate>Sun, 31 Oct 2021 13:23:25 +0800</pubDate><description><![CDATA[比较巧合，今天10.31，第一次尝试calendar set方法的时候就用了这个日期，但是一下忘了月份是从0开始的，传入的month参数没有用9而是用了10，代表11月，但11月只有30天，设置31号的话calendar会自动帮你设置到下一个月份的对应天数（12月1号，如果设置32号的话就会对应到12月2号，以此类推），而不是报错…迷惑了好久

...]]></description><category></category></item><item><title><![CDATA[C++ unique_lock使用笔记]]></title><link>https://blog.youkuaiyun.com/MCCreeper/article/details/120504024</link><guid>https://blog.youkuaiyun.com/MCCreeper/article/details/120504024</guid><author>MCCreeper</author><pubDate>Mon, 27 Sep 2021 10:59:59 +0800</pubDate><description><![CDATA[尝试使用unique_lock时出现unlock of unowned mutex，abort has been call等问题,在网上搜索了很久在其他文章中都没有找到解决办法,自己检查了几遍程序逻辑也没发现什么错误。排查了很久之后发现unique_lock变量被定义为全局变量,所有线程都能访问到lock变量,在各个线程中对同一个变量进行赋值操作会导致一些不可预测的问题,代码不规范。将lock改为局部变量问题就解决了…]]></description><category></category></item></channel></rss>