Memory Overrun! in MFC
-
Didn't you get the memo, Zac? Today is guess-what's-wrong-with-my-code-without-seeing-it day. ;)
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
Apparently it fell under the stack of memos reminding me to fill out my damn TPS reports.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
mostafa_pasha wrote:
there is memory overrun error & i do not know how can i solve that!
Don't overrun the end of your allocated memory. Mark
Mark Salsbery wrote:
Don't overrun the end of your allocated memory.
HI Mark, could you explain it further do you mean something like this int* pnSize=new int[10]; pnSize[10]=10;// which is not available delete [] pnSize;
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
Mark Salsbery wrote:
Don't overrun the end of your allocated memory.
HI Mark, could you explain it further do you mean something like this int* pnSize=new int[10]; pnSize[10]=10;// which is not available delete [] pnSize;
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
That is extremely well done, yes :) cheers, Mark
-
Mark Salsbery wrote:
Don't overrun the end of your allocated memory.
HI Mark, could you explain it further do you mean something like this int* pnSize=new int[10]; pnSize[10]=10;// which is not available delete [] pnSize;
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
Actually I was wrong about your code being "well done"... The original poster said "i allocate very large data". Therefore, your code sample should be: int* pnSize=new int[100]; pnSize[100]=10;// which is not available delete [] pnSize; :doh: Have a great day, Mark
-
Actually I was wrong about your code being "well done"... The original poster said "i allocate very large data". Therefore, your code sample should be: int* pnSize=new int[100]; pnSize[100]=10;// which is not available delete [] pnSize; :doh: Have a great day, Mark
excuse me for delay to response, //OVERRUN is for Pitch array ....
char *BeginFile = NULL; BeginFile = new char[44]; try { File.Read(BeginFile,44); } catch(CFileException *pe) { pe->ReportError(); } DWORD dwLength = (File.GetLength()-44); char *inChar ; inChar = new char[800000]; try { File.Read(inChar,dwLength); } catch(CFileException *pe) { pe->ReportError(); } File.Close(); int tmp; unsigned char c1,c2; double *in ; in = new double[400000]; int smp=dwLength/2; const int fs=22050; const int fc=7500; int kc = floor( (double)(fc * N / fs) )+1; int len=ceil((double)smp/N*2)+1; double *CBn ; CBn = new double[kc*len]; int sizeCB; sizeCB = Netmfile.Feature( in , kc ,smp , CBn ); int *Pitch = NULL; Pitch = new int[3000]; // :wtf:if use 2000 have OVERRUN PROBLEM IF use 3000 DO NOT HAVE OVERRUN PROBLEM:omg: // PitchExtract shown below int LenPitch = Netmfile.PitchExtract( in ,smp ,Pitch ); delete in; delete BeginFile; delete in; delete BeginFile; char weigthpath[]="text\\"; //path of MAT to TXT file double *CB1t ; CB1t = new double [kc*len]; Netmfile.net( CBn , CB1t , kc , weigthpath , sizeCB ); Netmfile.z = sizeCB * N - (sizeCB-1) * (N/2); smp2 = new double [Netmfile.z]; for (i=0 ; iN/2) { for ( j=p ; j>=i+1 ; j--) pichi [ j ] = pichi [ j - 1 ] ; pichi [ i ] = N/2; pichi [ i + 1 ] = m - N/2; m=0; p++; } i++; } return (p); }
-
excuse me for delay to response, //OVERRUN is for Pitch array ....
char *BeginFile = NULL; BeginFile = new char[44]; try { File.Read(BeginFile,44); } catch(CFileException *pe) { pe->ReportError(); } DWORD dwLength = (File.GetLength()-44); char *inChar ; inChar = new char[800000]; try { File.Read(inChar,dwLength); } catch(CFileException *pe) { pe->ReportError(); } File.Close(); int tmp; unsigned char c1,c2; double *in ; in = new double[400000]; int smp=dwLength/2; const int fs=22050; const int fc=7500; int kc = floor( (double)(fc * N / fs) )+1; int len=ceil((double)smp/N*2)+1; double *CBn ; CBn = new double[kc*len]; int sizeCB; sizeCB = Netmfile.Feature( in , kc ,smp , CBn ); int *Pitch = NULL; Pitch = new int[3000]; // :wtf:if use 2000 have OVERRUN PROBLEM IF use 3000 DO NOT HAVE OVERRUN PROBLEM:omg: // PitchExtract shown below int LenPitch = Netmfile.PitchExtract( in ,smp ,Pitch ); delete in; delete BeginFile; delete in; delete BeginFile; char weigthpath[]="text\\"; //path of MAT to TXT file double *CB1t ; CB1t = new double [kc*len]; Netmfile.net( CBn , CB1t , kc , weigthpath , sizeCB ); Netmfile.z = sizeCB * N - (sizeCB-1) * (N/2); smp2 = new double [Netmfile.z]; for (i=0 ; iN/2) { for ( j=p ; j>=i+1 ; j--) pichi [ j ] = pichi [ j - 1 ] ; pichi [ i ] = N/2; pichi [ i + 1 ] = m - N/2; m=0; p++; } i++; } return (p); }
First of all...what's going on in these sections....you left something out for (i=0 ; i smp2[i]=0; delete CBn; delete CB1t; delete Pitch; // have problem.......................use devpartner say OVERRUN } ... while (i { m=m+pichi[i]; if ... Mark
-
First of all...what's going on in these sections....you left something out for (i=0 ; i smp2[i]=0; delete CBn; delete CB1t; delete Pitch; // have problem.......................use devpartner say OVERRUN } ... while (i { m=m+pichi[i]; if ... Mark
excuse me for this fault, i do not know when i ignore HTML tags , the messeage is correct:confused: Netmfile.z = sizeCB * N - (sizeCB-1) * (N/2); //double *smp2; smp2 = new double [Netmfile.z]; for (i=0 ; iN/2) { for ( j=p ; j>=i+1 ; j--) pichi [ j ] = pichi [ j - 1 ] ; pichi [ i ] = N/2; pichi [ i + 1 ] = m - N/2; m=0; p++; //beacause of increase of Pitch length in each atage } i++; } return (p);
-
Actually I was wrong about your code being "well done"... The original poster said "i allocate very large data". Therefore, your code sample should be: int* pnSize=new int[100]; pnSize[100]=10;// which is not available delete [] pnSize; :doh: Have a great day, Mark
Mark Salsbery wrote:
The original poster said "i allocate very large data". Therefore, your code sample should be: int* pnSize=new int[100];
HE HE HE! :-D
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
excuse me for delay to response, //OVERRUN is for Pitch array ....
char *BeginFile = NULL; BeginFile = new char[44]; try { File.Read(BeginFile,44); } catch(CFileException *pe) { pe->ReportError(); } DWORD dwLength = (File.GetLength()-44); char *inChar ; inChar = new char[800000]; try { File.Read(inChar,dwLength); } catch(CFileException *pe) { pe->ReportError(); } File.Close(); int tmp; unsigned char c1,c2; double *in ; in = new double[400000]; int smp=dwLength/2; const int fs=22050; const int fc=7500; int kc = floor( (double)(fc * N / fs) )+1; int len=ceil((double)smp/N*2)+1; double *CBn ; CBn = new double[kc*len]; int sizeCB; sizeCB = Netmfile.Feature( in , kc ,smp , CBn ); int *Pitch = NULL; Pitch = new int[3000]; // :wtf:if use 2000 have OVERRUN PROBLEM IF use 3000 DO NOT HAVE OVERRUN PROBLEM:omg: // PitchExtract shown below int LenPitch = Netmfile.PitchExtract( in ,smp ,Pitch ); delete in; delete BeginFile; delete in; delete BeginFile; char weigthpath[]="text\\"; //path of MAT to TXT file double *CB1t ; CB1t = new double [kc*len]; Netmfile.net( CBn , CB1t , kc , weigthpath , sizeCB ); Netmfile.z = sizeCB * N - (sizeCB-1) * (N/2); smp2 = new double [Netmfile.z]; for (i=0 ; iN/2) { for ( j=p ; j>=i+1 ; j--) pichi [ j ] = pichi [ j - 1 ] ; pichi [ i ] = N/2; pichi [ i + 1 ] = m - N/2; m=0; p++; } i++; } return (p); }
mostafa_pasha wrote:
delete Pitch; // have problem.......................use devpartner say OVERRUN
Use
delete [] Pitch
instead. Allnew[]
must have a matchingdelete[]
.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
mostafa_pasha wrote:
delete Pitch; // have problem.......................use devpartner say OVERRUN
Use
delete [] Pitch
instead. Allnew[]
must have a matchingdelete[]
.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
Hi, but there is not diffrence , i think before i must use delete [] when i create two dimensional array in heap such as this: vf_Weigth = new float* [nlayer2+1]; for ( i =0 ; i< (nlayer2+1) ; i++) vf_Weigth[i] = new float[nlayer1]; delete [] vf_Weigth; // but now i find i delete in these way: for (int i = 0; i < nlayer2+1 ; i++) delete vf_Weight[i]; is that code is correct? at last i say again delete [] Pitch is not work & my code have that serios error. Best Regards. M.J.M.
-
Hi, but there is not diffrence , i think before i must use delete [] when i create two dimensional array in heap such as this: vf_Weigth = new float* [nlayer2+1]; for ( i =0 ; i< (nlayer2+1) ; i++) vf_Weigth[i] = new float[nlayer1]; delete [] vf_Weigth; // but now i find i delete in these way: for (int i = 0; i < nlayer2+1 ; i++) delete vf_Weight[i]; is that code is correct? at last i say again delete [] Pitch is not work & my code have that serios error. Best Regards. M.J.M.
You need to gain a further understanding of how
new
/delete
works, specifically with the [] notation. See: http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=36&rl=1[^] http://www.cplusplus.com/doc/tutorial/dynamic.html[^] http://www.glenmccl.com/bett_003.htm[^]
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Apparently it fell under the stack of memos reminding me to fill out my damn TPS reports.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac