about the access violation error at the malloc sentence
-
hi, the complier tell me this error happens at the statement of the malloc sentence, but I wonder how can this happens for this statement AT2[nAT2].itemset=(int *)malloc(sizeof(int)*up->lb[i].itemlen); usually when the pointer points to the invalid error or the array is out of index then this error happens, but now the very strange thing is I have run the program for 40hours then the error jump out? can anyone help me to analyze this error?
-
hi, the complier tell me this error happens at the statement of the malloc sentence, but I wonder how can this happens for this statement AT2[nAT2].itemset=(int *)malloc(sizeof(int)*up->lb[i].itemlen); usually when the pointer points to the invalid error or the array is out of index then this error happens, but now the very strange thing is I have run the program for 40hours then the error jump out? can anyone help me to analyze this error?
Use your debugger to check if up is a valid pointer and that i is in the range of the array.
Cédric Moonen Software developer
Charting control [v1.3] -
hi, the complier tell me this error happens at the statement of the malloc sentence, but I wonder how can this happens for this statement AT2[nAT2].itemset=(int *)malloc(sizeof(int)*up->lb[i].itemlen); usually when the pointer points to the invalid error or the array is out of index then this error happens, but now the very strange thing is I have run the program for 40hours then the error jump out? can anyone help me to analyze this error?
wendyyue wrote:
I have run the program for 40hours then the error jump out?
It looks like you'll spend a lot of time to find it out. BTW Have you checked if your process wastes memory? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
wendyyue wrote:
I have run the program for 40hours then the error jump out?
It looks like you'll spend a lot of time to find it out. BTW Have you checked if your process wastes memory? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarkeyes it does takes me a lot of time. just now I check the call stack find out that there is a problem in the following statement AT1=(int *)malloc(sizeof(int)*100); AT2=(int *)malloc(sizeof(int)*100); the AT1 can get the pointer and a valid value but the AT2 is 0x000000, can it means that the malloc did not allocate the memory for the AT2, because the memory is used up ? I have run it for 40 hours
-
yes it does takes me a lot of time. just now I check the call stack find out that there is a problem in the following statement AT1=(int *)malloc(sizeof(int)*100); AT2=(int *)malloc(sizeof(int)*100); the AT1 can get the pointer and a valid value but the AT2 is 0x000000, can it means that the malloc did not allocate the memory for the AT2, because the memory is used up ? I have run it for 40 hours
wendyyue wrote:
can it means that the malloc did not allocate the memory for the AT2, because the memory is used up ?
Yes, maybe your app is systematically eating up memory (some missing call to
free
?). :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
hi, the complier tell me this error happens at the statement of the malloc sentence, but I wonder how can this happens for this statement AT2[nAT2].itemset=(int *)malloc(sizeof(int)*up->lb[i].itemlen); usually when the pointer points to the invalid error or the array is out of index then this error happens, but now the very strange thing is I have run the program for 40hours then the error jump out? can anyone help me to analyze this error?
wendyyue wrote:
the complier tell me this error happens at the statement of the malloc sentence...I have run the program for 40hours then the error jump out?
This makes no sense. :confused: If you are running the program, then you cannot have compiler a error. If you have a compiler error, then you are not running the program.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne