QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Richard on October 09, 2021, 09:23:52 pm

Title: *** FIXED *** [dev build] $DEBUG _MEM problem *** string variable too large***
Post by: Richard on October 09, 2021, 09:23:52 pm
@FellippeHeitor


Is this a "feature" or a "bug"?

When F4 adding to watch list for _MEM stuff - can only add

+OFFSET
+SIZE
+TYPE
+ELEMENTSIZE
+IMAGE
+SOUND

cannot add

$_LOCK_ID
$_LOCK_OFFSET

as this results in

Error
Cannot add full UDT to Watch List





Title: Re: [dev build] $DEBUG _MEM problem
Post by: FellippeHeitor on October 09, 2021, 09:24:31 pm
Those are internal non-accessible elements.
Title: Re: [dev build] $DEBUG _MEM problem
Post by: Richard on October 09, 2021, 09:26:09 pm
OK thanks
Title: Re: [dev build] $DEBUG _MEM problem
Post by: Richard on October 09, 2021, 10:44:46 pm
@FellippeHeitor

I do not know if Windows is playing up on my computer - could you test the code below please?

As the code stands - the watch list values only lasts about 2 seconds and the program ends  (when it should be waiting at the last breakpoint a=a).


Code: QB64: [Select]
  1. $Debug
  2. redim shared m000~%%,m001~%%,a000$,a001$,w$
  3. A1:
  4.  
  5. sub A1:
  6. w$="ABC":a000$=".":a001$="."
  7. open "A:\test.txt" for binary as #1
  8. w&=lof(1):w$=space$(w&): get #1,,w$:close #1
  9. dim m as _mem:m = _memnew(5000000)
  10. _memput m,m.offset,w$
  11. _memget m,m.offset+0,m000~%%
  12. _memget m,m.offset+1,m001~%%
  13. _memget m,m.offset+0,a000$
  14. _memget m,m.offset+1,a001$
  15. a=a
  16.  
  17.  





  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Title: Re: [dev build] $DEBUG _MEM problem
Post by: FellippeHeitor on October 09, 2021, 10:59:32 pm
As long as the data you're fetching from the .txt file doesn't have anything special to it, the issue is something local to your machine. It worked alright here.
Title: Re: [dev build] $DEBUG _MEM problem
Post by: Richard on October 10, 2021, 12:40:30 am
@FellippeHeitor

Thanks for testing.

I still have a problem (though as you say it is specific to my system).

My file was 4,526,566 bytes which gave the problem.

Test file of 3 bytes was OK.

I slowly went through the process of trying to work out at what point the file failed me. It took me all this time since my last reply but it appears now that if I take only the first 2,087,490 bytes it seems to be OK. However if I take one extra than this (2,087,491) then I get the problem.


With the the code that I supplied you above - is it even possible that my file (~4.5 Mbytes) could possibly break debug (even if it was binary nonsense)???

Below are the trailing bytes (as seen by NotePad) for the 2,087,491 byte file which fails - when I take off the last character is appears to be fine.


X9Y1yOEqjSUer03E8y2xe4bcl0LCfK+0U0cHVw8ckKmnK6Tt5m3GcUwuPm6tbDpTe7jJq/zVmbN4
Ip7k36/VZmZqcx0MwRlH8I0t4bRHw6nOp0tdub8dvsh


Title: Re: [dev build] $DEBUG _MEM problem
Post by: FellippeHeitor on October 10, 2021, 12:43:44 am
In normal operation, you should have no issues with such a massive file. But in $Debug mode, if you read the whole file into a variable, and said variable is added to the watch list, you're really stretching it, since the Watch Panel will try to display the whole of it. Just don't add the culprit variable to the watch list and you should be able to use $Debug to find the issue you're investigating.
Title: Re: [dev build] $DEBUG _MEM problem
Post by: FellippeHeitor on October 10, 2021, 12:45:52 am
Also, please observe the limit for STRING variables: http://www.qb64.org/wiki/Variable_Types
Title: Re: [dev build] $DEBUG _MEM problem
Post by: Richard on October 10, 2021, 12:57:21 am
@FellippeHeitor

Thank you very much for quick response.

You were correct about the size of string for watching live.

By taking out $DEBUG and by NOT watching my w$ variable - WORKED AS EXPECTED!


Now that I know what the problem was (too big for $DEBUG) and the "magic" number at which strings being watched fail - I can apply very simple work-arounds should I need to inspect a variable (e.g. left$(w$, 2087490) extreme upper limit. Typically I only work with Mbyte size files (rarely Gbyte size).

Many thanks - all seems to be good for me now.
Title: Re: [dev build] $DEBUG _MEM problem
Post by: FellippeHeitor on October 10, 2021, 01:00:19 am
Alright, now come party with me at https://www.qb64.org/forum/index.php?topic=4275.msg136673#msg136673