funny crash, do you know why?
-
My app crashed, I did find probrlm point. to simplify code, I add a line inside crashed function for testing:
BYTE*pp=new BYTE[iSize];
iSize is an int, if iSize is 1016, the line is OK. if iSize is 1017, the line crashes, that is, the pointer can't be allocated, or pp is NULL. My PC has 2G memory, so memory should be OK. Do you know why? virus? VC problem? Project settings?
-
My app crashed, I did find probrlm point. to simplify code, I add a line inside crashed function for testing:
BYTE*pp=new BYTE[iSize];
iSize is an int, if iSize is 1016, the line is OK. if iSize is 1017, the line crashes, that is, the pointer can't be allocated, or pp is NULL. My PC has 2G memory, so memory should be OK. Do you know why? virus? VC problem? Project settings?
maybe the statement is executed many times before it crashes your app, as memory is really running low? you should show actual code to get effective help! :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
My app crashed, I did find probrlm point. to simplify code, I add a line inside crashed function for testing:
BYTE*pp=new BYTE[iSize];
iSize is an int, if iSize is 1016, the line is OK. if iSize is 1017, the line crashes, that is, the pointer can't be allocated, or pp is NULL. My PC has 2G memory, so memory should be OK. Do you know why? virus? VC problem? Project settings?
If that memory is not free'd then you have introduced a memory leak and as stated above me this could very well be the reason for the crash in that its running out of memory, but more code would help greatly.
-
My app crashed, I did find probrlm point. to simplify code, I add a line inside crashed function for testing:
BYTE*pp=new BYTE[iSize];
iSize is an int, if iSize is 1016, the line is OK. if iSize is 1017, the line crashes, that is, the pointer can't be allocated, or pp is NULL. My PC has 2G memory, so memory should be OK. Do you know why? virus? VC problem? Project settings?
includeh10 wrote:
My PC has 2G memory, so memory should be OK.
Be aware that each executable file has an header that hold information about the heap commit size and heap reserve size (see /HEAP (Set Heap Size)[^]); the reserve size has the meaning of the maximum stack size that your executable can use, and its default is 1 MB. If you are allocating more than 1 MB (both in a single shot or with multiple allocations), you can get a similar problem; it doesn't matter if your system is equipped with 2 GB.
-
My app crashed, I did find probrlm point. to simplify code, I add a line inside crashed function for testing:
BYTE*pp=new BYTE[iSize];
iSize is an int, if iSize is 1016, the line is OK. if iSize is 1017, the line crashes, that is, the pointer can't be allocated, or pp is NULL. My PC has 2G memory, so memory should be OK. Do you know why? virus? VC problem? Project settings?
Put the new inside a
try/catch
block which should give you some more information regarding the crash.try
{
BYTE*pp=new BYTE[iSize];
}
catch (exception& e)
{
cout << e.what();
}«_Superman_»
I love work. It gives me something to do between weekends. -
Put the new inside a
try/catch
block which should give you some more information regarding the crash.try
{
BYTE*pp=new BYTE[iSize];
}
catch (exception& e)
{
cout << e.what();
}«_Superman_»
I love work. It gives me something to do between weekends.«_Superman_» wrote:
try { BYTE*pp=new BYTE[iSize];}catch (exception& e){ cout << e.what();}
It one the correct way to resolve problem, but still there are some exception which can't be handlled by exception block too.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
Put the new inside a
try/catch
block which should give you some more information regarding the crash.try
{
BYTE*pp=new BYTE[iSize];
}
catch (exception& e)
{
cout << e.what();
}«_Superman_»
I love work. It gives me something to do between weekends. -
My app crashed, I did find probrlm point. to simplify code, I add a line inside crashed function for testing:
BYTE*pp=new BYTE[iSize];
iSize is an int, if iSize is 1016, the line is OK. if iSize is 1017, the line crashes, that is, the pointer can't be allocated, or pp is NULL. My PC has 2G memory, so memory should be OK. Do you know why? virus? VC problem? Project settings?
It could be a symptom of another memory problem elsewhere. Enable memory testing and rerun your program. It could also be (as someone else suggested) a memory leak being repeatedly executed. If so, this one is easy to fix: make the bb variable static and initially NULL. Then if it's not NULL, free it before assigning the new buffer to it.