Coder Social home page Coder Social logo

Comments (11)

userpro avatar userpro commented on August 17, 2024

贴一下复现代码

from memorypool.

lengkristy avatar lengkristy commented on August 17, 2024

#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.

lengkristy avatar lengkristy commented on August 17, 2024

反正用着就是很奇怪,我是通信服务端用的,并发也比较高

from memorypool.

userpro avatar userpro commented on August 17, 2024

你是并发场景下用吗 有打开readme里说明的线程安全的宏定义吗

:octocat: From gitme Android

from memorypool.

lengkristy avatar lengkristy commented on August 17, 2024

线程安全我是用的windows的机制WaitForSingleObject(mp->lock, INFINITE);

from memorypool.

lengkristy avatar lengkristy commented on August 17, 2024

感觉这里的释放逻辑好像有点BUG,我没有仔细看过你的代码,今天才开始用

from memorypool.

userpro avatar userpro commented on August 17, 2024

替换了MP_LOCK和MP_UNLOCK的宏定义吗

:octocat: From gitme Android

from memorypool.

lengkristy avatar lengkristy commented on August 17, 2024

嗯,我自己单独写了两个函数进行同步控制的:
//加锁
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.

lengkristy avatar lengkristy commented on August 17, 2024

这个不能粘短视频,不太好给你描述这个细节

from memorypool.

userpro avatar userpro commented on August 17, 2024

方便加个wx说吗

:octocat: From gitme Android

from memorypool.

lengkristy avatar lengkristy commented on August 17, 2024

我的微信号:lengkristy

from memorypool.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.