Operator "new" crashes application

Joined
Feb 15, 2011
Messages
2
Reaction score
0
Hello,

I have created a C++ application, and a class named Loader, which should read 5000 text files. For every new file, I am reserving memory using the code like this:

item[fileIndex].fileText = new wchar_t[item[fileIndex].fileLength + 1];

and then read the text from the file to item[fileIndex].fileText.

After reading all the files, I am deleting the object of type Loader and creat it again. In the class destructor I am deleting all the item[...].fileText pointers.

The problem is that after reading another 5000 files one or more times, the application crashes, most of the time at the point where I am using the "new" operator mentioned above.

What do you think is the cause and how to solve it?
 
Joined
Feb 15, 2011
Messages
2
Reaction score
0
By the way, if I limit the number of files to 1000, crashes are much less, but generally the situation is the same.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top