Comments (11)
贴一下复现代码
from memorypool.
#define MP_DLINKLIST_INS_FRT(head, x)
do {
x->prev = NULL;
x->next = head;
if (head) head->prev = x;
head = x;
} while (0)
在调用MemoryPoolFree的时候,ck = (_MP_Chunk*) ((char*) p - MP_CHUNKHEADER);计算得出cx的alloc_mem只有440,然后赋值给head,导致mp->mlist->free_list->alloc_mem为440。在没有赋值之前,这个mp->mlist->free_list->alloc_mem为1598532628。但是我看到在mp->mlist->free_list->next中mem为1598532628,导致下一次分配内存的时候就不能分配了
from memorypool.
反正用着就是很奇怪,我是通信服务端用的,并发也比较高
from memorypool.
你是并发场景下用吗 有打开readme里说明的线程安全的宏定义吗
from memorypool.
线程安全我是用的windows的机制WaitForSingleObject(mp->lock, INFINITE);
from memorypool.
感觉这里的释放逻辑好像有点BUG,我没有仔细看过你的代码,今天才开始用
from memorypool.
替换了MP_LOCK和MP_UNLOCK的宏定义吗
from memorypool.
嗯,我自己单独写了两个函数进行同步控制的:
//加锁
void MP_LOCK(MemoryPool* mp)
{
do
{
#ifdef MS_WINDOWS
WaitForSingleObject(mp->lock, INFINITE);
#endif
} while (0);
}
//解锁
void MP_UNLOCK(MemoryPool* mp)
{
do
{
#ifdef MS_WINDOWS
SetEvent(mp->lock);
#endif
} while (0);
}。
from memorypool.
这个不能粘短视频,不太好给你描述这个细节
from memorypool.
方便加个wx说吗
from memorypool.
我的微信号:lengkristy
from memorypool.
Related Issues (13)
- issues for auto-extended HOT 1
- mem leak HOT 1
- 关于list分区 HOT 1
- 关于void* MemoryPoolAlloc(MemoryPool* mp, mem_size_t wantsize)部分的逻辑疑问
- bug:static int merge_free_chunk(MemoryPool* mp, _MP_Memory* mm, _MP_Chunk* c)
- 初始化时,空闲块尾指针应当指向首地址
- merge_free_chunk报错 HOT 3
- 关于释放内存报错 HOT 2
- 大哥,我用了你的代码,内存释放报错 HOT 3
- 在调用get_mempool_usage方法时,突然返回一个很大的值 HOT 3
- 是否保证线程安全 HOT 1
- 建议区分一下读写场景,然后根据不同场景加读写锁可以提高并发场景下的性能
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memorypool.