• Print

Author Topic: SETMEM/FRE  (Read 1931 times)

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 4664
  • QB Forever
    • Email
SETMEM/FRE
« on: December 04, 2009, 02:28:00 AM »
No work has been done on this command yet.
Something old... Something new... Something borrowed... Something blue...

SkyCharger001

  • Hero Member
  • *****
  • Posts: 1594
Re: SETMEM/FRE
« Reply #1 on: March 22, 2011, 11:52:36 AM »
FRE could be a handy tool for tracing memory-leaks

Clippy

  • Hero Member
  • *****
  • Posts: 16431
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: SETMEM/FRE
« Reply #2 on: March 22, 2011, 12:46:31 PM »
Hopefully QB64 will be able to limit those kinds of problems! We certainly should not have to deal with the problems that DOS created!

The only thing that programmers would need is to remember to free resources when they are no longer needed and to LIMIT loop speeds when possible. Windows and other OS's may not take kindly to "outside" memory management!
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

SkyCharger001

  • Hero Member
  • *****
  • Posts: 1594
Re: SETMEM/FRE
« Reply #3 on: March 22, 2011, 05:31:25 PM »
one acceptable way to make this work is to translate SETMEM/FRE into request-calls to the system's memory manager, and thus hopefully make them acceptable to the system.
EG:
program needs 64MB of RAM to run. (QB64 programs that would fit this are rare at the moment)
SETMEM sends a request to allocate a MINIMUM of 64MB RAM.
FRE then checks the actually allocated RAM.
if RAM is BELOW 64MB then program closes with 'insufficient memory' error BEFORE it has wasted a lot of time on loading.

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 4664
  • QB Forever
    • Email
Re: SETMEM/FRE
« Reply #4 on: March 23, 2011, 12:17:57 PM »
The problem is that QBASIC programs just don't expect there to be more than 640KB available, so returning the actual free memory of your computer might break compatibility with those programs. I think FRE should return the amount of emulated conventional memory left.
Something old... Something new... Something borrowed... Something blue...

Clippy

  • Hero Member
  • *****
  • Posts: 16431
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: SETMEM/FRE
« Reply #5 on: March 23, 2011, 12:30:30 PM »
It might just be best to ignore memory management in old Qbasic programs like it does now.

Ted

PS: This site was down for a bit this afternoon.
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

Dark Star

  • Hero Member
  • *****
  • Posts: 532
Re: SETMEM/FRE
« Reply #6 on: August 10, 2011, 03:03:31 PM »
Herein lies the difference between a good programmer and a sloppy one; if you are unable to track your own memory requirements, don't expect someone else to be able to.  If memory of BASIC serves, those commands are called "DIM" and "ERASE"; but suppose that you know your program will eventually consume all available memory, all available swap file, all available hard drive space, AND still want more, much, much more?  What then?  A sloppy programmer such as myself resorts to using strings to accomplish everyday tasks, but suppose for one moment that your system operated on the principle that you had to earn every bit you had at your disposal, just like in the early days when this was precisely the case.  Would you, as a Programmer, be able to operate under those constraints?
PPP  ???

SkyCharger001

  • Hero Member
  • *****
  • Posts: 1594
Re: SETMEM/FRE
« Reply #7 on: August 10, 2011, 03:19:32 PM »
the problem is when your program is meant only as a subset or engine.
example 1: your code forms a sound engine... wouldn't do if it used even close to all memory available to the game it's part of.
example 2: you make something like AGI/SCI/SCUMM... it needs to know if it has the memory for what it's trying to load.

Cyperium

  • Hero Member
  • *****
  • Posts: 3285
  • Knowledge is good, but understanding is better
    • Cyperium
    • Email
Re: SETMEM/FRE
« Reply #8 on: August 12, 2011, 02:19:54 PM »
You could make a optional argument that would return the actual memory and just let the FRE represent the emulated memory (always return 640K).
Venture - New Prototype, QB64 Editor v1.95b (linux compatible, if you compile the source).

SkyCharger001

  • Hero Member
  • *****
  • Posts: 1594
Re: SETMEM/FRE
« Reply #9 on: August 16, 2011, 12:35:53 PM »
Quote from: Cyperium on August 12, 2011, 02:19:54 PM
You could make a optional argument that would return the actual memory and just let the FRE represent the emulated memory (always return 640K).
even when emulating a TSR? The TSR could find itself crippled by the QB-program writing in it's program-space.

Cyperium

  • Hero Member
  • *****
  • Posts: 3285
  • Knowledge is good, but understanding is better
    • Cyperium
    • Email
Re: SETMEM/FRE
« Reply #10 on: September 14, 2011, 02:54:58 PM »
True, then perhaps it should return whatever memory that QB would have returned (simulate memory usage).


Is it even possible to emulate TSR's at this point? We don't have a DOS environment to return to when it terminates, so where would it stay resident? I guess you could make the program window invisible and just letting the program run, to have it active in the "background" but I don't perceive that as a TSR.
Venture - New Prototype, QB64 Editor v1.95b (linux compatible, if you compile the source).

Clippy

  • Hero Member
  • *****
  • Posts: 16431
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: SETMEM/FRE
« Reply #11 on: September 14, 2011, 03:19:48 PM »
Windows holds stuff in memory so that previously loaded programs start up faster. I'm glad that QB64 doesn't do that and hope it never will! I have to reboot when too much is saved.
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

  • Print