Здравствуйте, Sergey, Вы писали:
S>Можно взглянуть на текст ошибки? И в output окно отладчика оно что-нибудь при возникновении ошибки пишет?
[15.08.2007 15:12:08] [ 127.0.0.1:03650] [<] [3084] 002 22 00
[15.08.2007 15:12:08] [ 127.0.0.1:03650] [>] [3084] 004:013 22 08 16 00
[15.08.2007 15:12:08] [ 213.87.86.60:10024] [<] [1248] 006 22 08 16 00 85 FE
First-chance exception at 0x77e4bee7 in decsrv.exe: Microsoft C++ exception: ufoException::EStreamError @ 0x00d5f980.
[15.08.2007 15:12:08] [ 127.0.0.1:03650] [E] Ошибка сокета: Out of memory while expanding memory stream
First-chance exception at 0x77e4bee7 in decsrv.exe: Microsoft C++ exception: [rethrow] @ 0x00000000.
[15.08.2007 15:12:08] [ 127.0.0.1:03650] [M] Отключение.
[15.08.2007 15:12:08] [M] [2088] Устройство закрыто.
PtUskLib: DLL_PROCESS_DETACH'decsrv.exe': Unloaded 'C:\DevSrc\(.NET)\(Vc7)\Configurator\decsrv\Debug\PtUskVC.dll'
'decsrv.exe': Unloaded 'C:\WINDOWS\system32\wsock32.dll'
The thread 'Win32 Thread' (0x828) has exited with code 0 (0x0).
[15.08.2007 15:12:08] [M] [3084] Устройство закрыто.
The thread 'Win32 Thread' (0xc0c) has exited with code 0 (0x0).
[15.08.2007 15:12:08] [M] [3312] Устройство закрыто.
The thread 'Win32 Thread' (0xcf0) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x408) has exited with code 0 (0x0).
First-chance exception at 0x77e4bee7 in decsrv.exe: Microsoft C++ exception: ufoException::EStreamError @ 0x00edd820.
[15.08.2007 15:12:09] [ 213.87.86.111:05793] [M] Out of memory while expanding memory stream
First-chance exception at 0x77e4bee7 in decsrv.exe: Microsoft C++ exception: ufoException::EStreamError @ 0x00fdd820.
[15.08.2007 15:12:09] [ 213.87.86.60:10024] [M] Out of memory while expanding memory stream
First-chance exception at 0x77e4bee7 in decsrv.exe: Microsoft C++ exception: ufoException::EStreamError @ 0x00edd820.
[15.08.2007 15:13:11] [ 213.87.86.111:05793] [M] Out of memory while expanding memory stream
First-chance exception at 0x77e4bee7 in decsrv.exe: Microsoft C++ exception: ufoException::EStreamError @ 0x00fdd820.
[15.08.2007 15:13:11] [ 213.87.86.60:10024] [M] Out of memory while expanding memory stream
First-chance exception at 0x71bb30d1 in decsrv.exe: 0xC0000005: Access violation reading location 0x71bb30d1.
Unhandled exception at 0x71bb30d1 in decsrv.exe: 0xC0000005: Access violation reading location 0x71bb30d1.
Сейчас я выделяю блоки памяти через GlobalAlloc, и именно здесь возникает ошибка:
Pointer CMemoryStream::Realloc(int &NewCapacity)
{
if ( (NewCapacity > 0) && (NewCapacity != m_Size) )
NewCapacity = (NewCapacity + (MemoryDelta - 1)) & ~(MemoryDelta - 1);
Pointer P = Memory;
if ( NewCapacity != m_Capacity )
{
if ( NewCapacity == 0 )
{
GlobalFreePtr(Memory);
P = NULL;
}
else
{
if ( m_Capacity == 0 )
P = GlobalAllocPtr(GMEM_MOVEABLE, NewCapacity);
else
P = GlobalReallocPtr(Memory, NewCapacity, GMEM_MOVEABLE);
if ( P == NULL )
throw EStreamError(_T("Out of memory while expanding memory stream"));
}
}
return P;
};
где Pointer это void*
Pointer GlobalAllocPtr(int Flags, unsigned long Bytes)
{
return ::GlobalLock(::GlobalAlloc((UINT) Flags, (SIZE_T) Bytes));
};
//-----------------------------------------------------------------------------------------------------------------------
Pointer GlobalReallocPtr(Pointer P, unsigned long Bytes, int Flags)
{
::GlobalUnlock(::GlobalHandle(P));
return ::GlobalLock(::GlobalReAlloc(P, (SIZE_T) Bytes, (UINT) Flags));
};
//-----------------------------------------------------------------------------------------------------------------------
HANDLE GlobalFreePtr(Pointer P)
{
::GlobalUnlock(::GlobalHandle(P));
return ::GlobalFree(P);
};
//-----------------------------------------------------------------------------------------------------------------------
Когда было так:
Pointer CMemoryStream::Realloc(int &NewCapacity)
{
if ( (NewCapacity > 0) && (NewCapacity != m_Size) )
NewCapacity = (NewCapacity + (MemoryDelta - 1)) & ~(MemoryDelta - 1);
Pointer P = Memory;
if ( NewCapacity != m_Capacity )
{
if ( NewCapacity == 0 )
{
::HeapFree(::GetProcessHeap(), 0, Memory);
P = NULL;
}
else
{
if ( m_Capacity == 0 )
P = (Pointer) ::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, NewCapacity);
else
P = (Pointer) ::HeapReAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, Memory, NewCapacity);
if ( P == NULL )
throw EStreamError(_T("Out of memory while expanding memory stream"));
}
}
return P;
};
то в Output предварительно писалось heap corruption detected.
S>Не нужно.
Вот и я о том же. Спасибо.