Maximum Length on New Double

Hi guys!

I’m having some troubles on a Class that I’m creating.

int HNM::GenerateHarmonicComponent(){
         int HC_length = 60000;       
         double *HarmonicComponent = new double [ HC_length ];
         /* All the code of the function is in comments */
        return 1;
}

On that case the code compiles fine and my program starts working for 6 seconds until a Windows message “EmpyExample.exe has stopped working” appears and everything crash
But I detected instead of having 60000 having some other smaller number, like :

HC_length = 60;       
double *HarmonicComponent = new double [ HC_length ];

then everything works fine as long as it should.

Does anyone have any hints of what can be causing the problem? It may be because of reaching the maximum length of ‘new double’?

Thank you! :slight_smile:

Are you deleting that HarmonicComponent pointer after you allocate it? If not, you’re leaking a lot of memory and that would explain the crashes.

Yes, I am. Sorry I didn’t write it before.
Ok, I’m going to check all the others functions to be sure of that.

Thanks Joshua!

Looks like almost everything but 2 or 3 char strings was being delete. No significant change after that.

I think I’ll try to put that HarmonicComponent as a double vector and see what happens.