|
本帖最后由 yleesun 于 2013-3-19 08:14 编辑
最近在研究你写的服务器代码。现有一个问题请教:
在服务器运行的过程中,经常在发送数据的时候,会在ACE_Message_Block* CMessageBlockManager::Create(uint32 u4Size)中报错。错误指向了Malloc_T.cpp的函数:
emplate <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> void *
ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_malloc (size_t nbytes)
{
#if !defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
ACE_TRACE ("ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_malloc");
#endif /* !ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
if (this->cb_ptr_ == 0)
return 0;
// Round up request to a multiple of the MALLOC_HEADER size.
size_t const nunits =
(nbytes + sizeof (MALLOC_HEADER) - 1) / sizeof (MALLOC_HEADER)
+ 1; // Add one for the <MALLOC_HEADER> itself.
MALLOC_HEADER *prevp = 0;
MALLOC_HEADER *currp = 0;
ACE_SEH_TRY
{
// Begin the search starting at the place in the freelist where the
// last block was found.
prevp = this->cb_ptr_->freep_;
currp = prevp->next_block_;
}
#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
ACE_SEH_EXCEPT (this->memory_pool_.seh_selector (GetExceptionInformation ()))
{
currp = prevp->next_block_;
}
#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
// Search the freelist to locate a block of the appropriate size.
while (1)
// *Warning* Do not use "continue" within this while-loop.
{
ACE_SEH_TRY
{
if (currp->size_ >= nunits) // Big enough 在这里出错。
{
ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.ninuse_);
if (currp->size_ == nunits)
请指教。这个错误,是经常出现,不是每次必出现。 |
|