Author Topic: "Out of Memory" mystery  (Read 7933 times)

0 Members and 1 Guest are viewing this topic.

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: "Out of Memory" mystery
« Reply #15 on: September 24, 2018, 08:13:02 am »
Thank you, Steve. That works perfectly in the application. It's behaving itself now. Would that be a QB64 issue then?

That also explains why my character handling program doesn't have this issue, it uses no TABs. Certainly not loop called ones.

Entry_Print, with it's TAB statements, has been around since the very early days of development. The application is at least 20 years old, and most likely older. It was only later that I got more into using LOCATE for output formatting. In fact, I wasn't aware that row references in LOCATE were optional, so I will be excising TAB from my coding efforts for a while.

I think what happened to the EXEICON was that I compiled the program when the ico file was in the root directory. I later moved all image files to the 'images' directory but forgot to change the path to the ico. I'm kinda like a dwarf playing in his treasure hoard, so intent upon playing with the shiny baubles that he forgets to take a potty break...poor coding hygiene....

I also want to shout out a big thank you to Terry again, I never thought of Task Manager as a debugging tool before he suggested it. I wouldn't have had a clue without it.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: "Out of Memory" mystery
« Reply #16 on: September 24, 2018, 01:19:51 pm »
Removing the use of TAB corrects the issue.  Apparently TAB has a memory leak in it somewhere:

Code: QB64: [Select]
  1.     Entry_Print
  2.  
  3.  
  4. SUB Entry_Print '(entry AS LoadRecord)
  5.  
  6.     '-------------------------DISPLAY----------------------------------------------------
  7.     ' SUB: Entry_Print
  8.     '
  9.     ' Purpose:
  10.     ' Displays tabbed data from record number passed by 'entry' when called.
  11.     '
  12.     ' Passed parameters:
  13.     ' entry sends the load record for display
  14.     '
  15.     ' Called from:
  16.     ' Add_Record, Edit_File, Refresh_Screen, and View_File
  17.     '
  18.     '-----------------------------------------------------------------------------------
  19.  
  20.     LOCATE , 1: PRINT USING "###   "; entry.load;
  21.     LOCATE , 6: PRINT entry.Date;
  22.     LOCATE , 17: PRINT entry.Time;
  23.     LOCATE , 28: PRINT RTRIM$(entry.truck$);
  24.     LOCATE , 37: PRINT USING "###,###"; entry.Gross;
  25.     LOCATE , 45: PRINT USING "###,###"; entry.Net;
  26.     LOCATE , 54: PRINT USING "#,###.##"; entry.Wet;
  27.     LOCATE , 64: PRINT USING "##.##"; entry.Test;
  28.     LOCATE , 70: PRINT USING "#,###.##"; entry.Dry
  29.  
  30. END SUB 'Entry_Print
  31.  

I mentioned the possibility of a memory leak, but wow Steve, you hunted that down fast! I hope it can be fixed in an upcoming version of QB64. Tab isn't used much, I suspect, so it doesn't surprise me if this is a memory leak, it hasn't been found until now.

I remember when I used to debug programs while Rob was developing. If my program threw an error, and I knew it wasn't coming from my code, I had to piece by piece eliminate things in the code until I removed a line that removed the problem. Then I'd report it so it could be fixed. Ah, those were the days... and I don't miss them one friggin' bit!

Pete :D
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: "Out of Memory" mystery
« Reply #17 on: September 24, 2018, 01:40:05 pm »
I've had a chance to run the program in its working environment this morning, running Task Manager in the background. It was still ticking up slightly, although it would have taken a week of constant running to fill up. I went looking for more TABs and found a few in the loop associated with printing out totals. After removing them, it holds steady at under 40 MB when not actually processing input.

It would seem to confirm that TAB is a troublemaker.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: "Out of Memory" mystery
« Reply #18 on: September 24, 2018, 02:42:09 pm »
Quote
Thank you, Steve. That works perfectly in the application. It's behaving itself now. Would that be a QB64 issue then?

It is.   I took a look inside libqb last night and found the function for tab (func_tab, maybe?  I was half asleep and don't remember the exact name for it...).   From initial impressions, I'm going to assume it's similar to the memory leak PRINT used to have:  it looks as if the routine uses qbs_new to allocate memory for a few temporary QBStrings, but then it doesn't qbs_free them.

The fix may be as simple as freeing the strings before leaving the routine, and if so, somebody should be able to sort that glitch out rather quickly and push the needed change into the repo.   ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!