Results 1 to 8 of 8

Thread: memory allocation problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    58
    Thanks
    1

    Default memory allocation problem

    Hi.

    I do a memory allocation using 'new', as follow.

    Qt Code:
    1. double *myarray[50];
    2. for (int j = 0; j < 50; j++)
    3. myarray[j] = new double[100000];
    To copy to clipboard, switch view to plain text mode 

    When the codes first run it works. When I rerun it, (e.g. when user click the button again) the program crash. I tried to debug but couldnt find an answer. What is the right way to "trap" such memory allocation codes in QT? And is there a better way to allocate an array of pointers to double in QT?

    I also delete the allocation as needed by the following codes
    Qt Code:
    1. for (int j = 0; j < 50; j++)
    2. delete [] myarray[j]
    To copy to clipboard, switch view to plain text mode 

    Thanks!
    Last edited by Lykurg; 20th May 2011 at 06:31.

Similar Threads

  1. Widget Memory Allocation
    By ArlexBee-871RBO in forum Qt Programming
    Replies: 5
    Last Post: 9th May 2010, 19:51
  2. Virtual memory allocation problem
    By morfei in forum Qt Programming
    Replies: 1
    Last Post: 27th August 2009, 11:30
  3. QDrag : memory allocation
    By kghose in forum Qt Programming
    Replies: 1
    Last Post: 14th August 2008, 22:57
  4. limit memory allocation
    By magland in forum General Programming
    Replies: 10
    Last Post: 23rd March 2007, 09:21
  5. vector memory allocation
    By TheKedge in forum General Programming
    Replies: 1
    Last Post: 23rd March 2006, 17:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.