I have a problem with new operator failing to allocate memory sometimes when running the piece of code below. Usually when I hits between 200 to 400 it fails.
There is a lot more going on within the program other than this piece of code and this code is contained within a dll.
The machine that the code is running on is windows xp sp2 with 1G RAM so I do not understand how it can fail to allocate memory and I have verified that there is enough memory available.
Does anyone have any ideas why new fails in this suggestion or why new would fail at all?
thanks
char **m_pszDotCodeLine;
m_pszDotCodeLine = new char*[1000];
for (i = 0; i < 1000; i++)
{
try
{
m_pszDotCodeLine = new char[200];
}
catch(...)
{
throw Exception(pstDLLError, INSUFF_MEM, FAIL, P_NEWNOTE, 999);
)
memset(m_pszDotCodeLine, NULL, 200);
}
}
There is a lot more going on within the program other than this piece of code and this code is contained within a dll.
The machine that the code is running on is windows xp sp2 with 1G RAM so I do not understand how it can fail to allocate memory and I have verified that there is enough memory available.
Does anyone have any ideas why new fails in this suggestion or why new would fail at all?
thanks
char **m_pszDotCodeLine;
m_pszDotCodeLine = new char*[1000];
for (i = 0; i < 1000; i++)
{
try
{
m_pszDotCodeLine = new char[200];
}
catch(...)
{
throw Exception(pstDLLError, INSUFF_MEM, FAIL, P_NEWNOTE, 999);
)
memset(m_pszDotCodeLine, NULL, 200);
}
}