Operator "new" crashes application

Discussion in 'C Programming' started by pamir, Feb 17, 2011.

  1. pamir

    pamir

    Joined:
    Feb 15, 2011
    Messages:
    2
    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?
     
    pamir, Feb 17, 2011
    #1
    1. Advertising

  2. pamir

    pamir

    Joined:
    Feb 15, 2011
    Messages:
    2
    By the way, if I limit the number of files to 1000, crashes are much less, but generally the situation is the same.
     
    pamir, Feb 17, 2011
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Rebbeck

    ASP.NET application times out or crashes

    John Rebbeck, Nov 6, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    362
    John Rebbeck
    Nov 6, 2003
  2. Nemo

    Why delete operator crashes

    Nemo, Feb 23, 2006, in forum: C Programming
    Replies:
    7
    Views:
    302
    Default User
    Feb 23, 2006
  3. saikishore.vanga@wipro.com
    Replies:
    8
    Views:
    354
    Neil Cerutti
    Dec 22, 2005
  4. Nemo
    Replies:
    13
    Views:
    494
  5. xmllmx
    Replies:
    6
    Views:
    435
    xmllmx
    Feb 3, 2010
Loading...

Share This Page