Results 1 to 5 of 5

Thread: QList: Out of Memory Error

  1. #1
    Join Date
    May 2009
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QList: Out of Memory Error

    I've been trying to work around this runtime mayhem for past 24 with no avail.
    I'm a beginner, and have no knowledge about the inbuilt debugger in Qt4. I've tried to run the program sans the Qt GUI, and it works fine.

    I've narrowed down the OOM killer to a function getWildCards(word); But I'm not sure what wrong I'm doing in there and moreover I'm not using QList anywhere in the entire program to get that error.

    Qt exits the program with a "Microsoft Visual C++ Runtime Error" and a code 3.

    Here's the code snippet.

    Qt Code:
    1. void MainWindow::spellCheck() { //a private slot
    2. QByteArray qB = ui->lineEditWord->text().toLatin1();
    3. char* word = (char *) qB.data(); //casts QByteArray to char*
    4. QString string;
    5.  
    6. ui->txtEditMain->insertPlainText(" ");
    7. ui->txtEditMain->insertPlainText(ui->lineEditWord->text());
    8.  
    9. ui->txtEditSpell->setText(QString::null);
    10.  
    11. WDict->spellcheck(word,2); //calls a spellchecker, WDict is a private *member
    12. for(int i=0; i<WDict->sw.ubound; i++) { //WDict->sw.ubound is upper bound for the iteration
    13. string = (QString(QLatin1String(WDict->sw.valid_words[i])).toLower());
    14. if(string.isEmpty()!=true)
    15. ui->txtEditSpell->append(string);
    16. string.clear();
    17. }
    18. ui->lblSpell->setText(QString::number(WDict->sw.ubound).append(" Spellings"));
    19.  
    20. ui->txtEditWild->setText(QString::null);
    21. ui->lineEditWord->setText(QString::null);
    22. getWildcards(word); //<--------the problem occurs when this function is called
    23. }
    24.  
    25. void MainWindow::getWildcards(char* word) { //the problematic function!
    26. QString string2;
    27.  
    28. WDict->trie_wildcard_print(word); //calls a function which works perfectly fine
    29. for(int i=0; i<WDict->sw.ubound; i++) { //on an average ubound is about 300
    30. string2 = QString(QLatin1String(WDict->sw.valid_words[i])); //valid_words is 600long and 64wide
    31. string2.toLower();
    32. ui->txtEditWild->append(string2);
    33. string2.clear();
    34. }
    35. ui->lblWild->setText(QString::number(WDict->sw.ubound).append(" Wild Cards"));
    36. }
    To copy to clipboard, switch view to plain text mode 


    Merci en avance.
    Last edited by ignoramous; 15th May 2009 at 06:05.

  2. #2
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: QList: Out of Memory Error

    If I were you, I'd debug the application and search where and when your program is out of memory (just a breakpoint inside the function and follow the variables)

    But seems like you have a problem in WDict->sw.valid_words[i], maybe in some moment you are searching inside sw and position i doesn't exist.

    Also, if you are working with Visual Studio, check if "this" pointer is always active or the debugger "deletes" it. If you have the default configuration of visual studio, sometimes, the this pointer could be deleted, reborn again, be deleted again... it's kinda strange but it happened to me twice.

  3. The following user says thank you to jano_alex_es for this useful post:

    ignoramous (15th May 2009)

  4. #3
    Join Date
    May 2009
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QList: Out of Memory Error

    I'm working with Qt Creator(the ui-> pointer thing makes it obvious?). And never does the index 'i' exceed the arraybounds. I've checked that with gdb.

    The error Qt throws seems to be random (at least to me) when I call that function (getWildCards(word)) and most of the times it throws no error at all. I cannot know why this happens. For most part it seemed like the error was in the function trie_wildcard_print, but again gdb showed it to work well without any traces of leaks or illegal access.

    And back to the errors that Qt throws, most frequently a dialog box with "Microsoft Visual C++ Runtime Library Error," some other times "QMutex: lock: Deadlock detected in Thread <threadno>," or it just exits with a code 128 or code 3. I'm using no threads whatsoever.

    Also I'd be glad if you can point me to a good tutorial on using this inbuilt Qt Creator debugger. I've searched but didn't find a website that would explain it in simple English.

    Thanks once again for your reply .

  5. #4
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: QList: Out of Memory Error

    I'm working with Qt Creator(the ui-> pointer thing makes it obvious?)

    Not really... if you work with the Visual Studio Integrator it creates and sets up the ui object as well :P One of your error messages was "Microsoft Visual C++ Runtime Error" so I though you were working with Visual Studio.

    I don't have a clue... if I were you I'll try to uninstall and install again everything :S Maybe an installation problem...

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QList: Out of Memory Error

    Let me guess - you are using multiple threads in your application, right?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 13:43
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  3. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 02:49
  4. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19
  5. Qt-x11-commercial-src-4.2.0-snapshot-20060824 error
    By DevObject in forum Installation and Deployment
    Replies: 4
    Last Post: 24th August 2006, 23:31

Tags for this Thread

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.