Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Game is crashing due to out of memory (48k) (*solved*)
#1
Bug 
Hi

I am writing a text adventure game (simply for my own fun) rather than use the other systems out there e.g. PAW Infocom, DAAD, TADS,  Aventuron etc... I wanted the challenge in writing one for the ZX Spectrum . :-)

The biggest issue I had was the amount of Text that needed storing.
At first I was going to use some sort of compression but couldn't get it work so I created a tokenised dictionary that turned string arrays (Locations, Objects, Examination results etc...)  to numeric arrays thus the memory was reduced quite a bit. So I thought this would suffice but I soon ran out of memory.

I then attempted to look into the text compression again and then worked out how to do this, but due to the size of the dictionary which was needed still it crashed when there was a decompression of the location file.

I also attempted to use +3 Disk but whilst I was able to a) load a picture b) load a text it crashed subsequent attempts. (Memory clash perhaps)?

So I am here looking for some hints/tips on the options I have.
I do have another plan though where I will try to rewrite it but this time start using text compression from the start.... we will see ... but the main thing for me is

Thanks to Boriel bringing the ZXB to use and Einar Saukas for their both their support :-)
Reply
#2
UPDATE:
I have now moved all the .BAS files that originally segregated into modules into one file and now the ZX0 compression routines are working.

A new Out of memory is now being displayed but I am not sure why?

Compiling with the following (Not the big heap) 
--tzx --BASIC --autorun  --heap=4800 --optimize 3 --org=25000  --debug-memory  --debug-array

Putting an output of the memory just before the line that causes it 
i.e. EX$(AVL) = ExitsDesc(LOC)

mem avl 3515
mem MaxAvl 1571


and you can see there is plenty of available memory.

I am decompressing to 62000 (F230) so it is out of the way

Next the memory map. Below you can see the program starts at 25,000 (61A8) and ends at 59,402


Quote:61A8: .core.__START_PROGRAM
61C1: .core.__CALL_BACK__
61C3: .core.ZXBASIC_MEM_HEAP
61C3: .core.ZXBASIC_USER_DATA
7483: ._GX
7485: ._GY

..
..
..
E78E: .core.__STRGT
E79C: .core.__STRGE
E7A4: .core.__FREE_STR
E7BA: .core.__STRSLICE
E7BE: .core.__STRSLICE_FAST
E805: .LABEL.__LABEL645
E808: .LABEL.__LABEL649
E80A: .LABEL.__LABEL650

So I am not sure how/why it running out of memory.  

Could the out of memory error be a false message, could it be a memory address clash?

Any tips would be useful.

Thank you in advance.

UPDATE - SOLVED :

Okay I found out the issue !
DIM MSG1 as UBYTE = 0
DIM MSG2 as UBYTE = 1
DIM MSG3 as UBYTE = 2
DIM A$(10)
A$(MSG1) = "Msg 1 on page 1"
A$(MSG2) = "Msg 2 on page 1"
A$(MSG3) = "Msg 2 on page 1"

So changing it to this works
A$(1) = "Msg 1 on page 1"
A$(2) = "Msg 2 on page 1"
A$(3) = "Msg 3 on page 1"

The above is only an example but still shows the error which is actually correct.
To be exact the compiler should complain about DIM A$(MSG1) is not valid instead it compiles then gives the out of memory message.

:-)

Thanks
Reply
#3
(04-26-2021, 05:48 PM)RandomiserUsr Wrote: UPDATE:
I have now moved all the .BAS files that originally segregated into modules into one file and now the ZX0 compression routines are working.

A new Out of memory is now being displayed but I am not sure why?

Compiling with the following (Not the big heap) 
--tzx --BASIC --autorun  --heap=4800 --optimize 3 --org=25000  --debug-memory  --debug-array

Putting an output of the memory just before the line that causes it 
i.e. EX$(AVL) = ExitsDesc(LOC)

mem avl 3515
mem MaxAvl 1571


and you can see there is plenty of available memory.

I am decompressing to 62000 (F230) so it is out of the way

Next the memory map. Below you can see the program starts at 25,000 (61A8) and ends at 59,402


Quote:61A8: .core.__START_PROGRAM
61C1: .core.__CALL_BACK__
61C3: .core.ZXBASIC_MEM_HEAP
61C3: .core.ZXBASIC_USER_DATA
7483: ._GX
7485: ._GY

..
..
..
E78E: .core.__STRGT
E79C: .core.__STRGE
E7A4: .core.__FREE_STR
E7BA: .core.__STRSLICE
E7BE: .core.__STRSLICE_FAST
E805: .LABEL.__LABEL645
E808: .LABEL.__LABEL649
E80A: .LABEL.__LABEL650

So I am not sure how/why it running out of memory.  

Could the out of memory error be a false message, could it be a memory address clash?

Any tips would be useful.

Thank you in advance.

UPDATE - SOLVED :

Okay I found out the issue !
DIM MSG1 as UBYTE = 0
DIM MSG2 as UBYTE = 1
DIM MSG3 as UBYTE = 2
DIM A$(10)
A$(MSG1) = "Msg 1 on page 1"
A$(MSG2) = "Msg 2 on page 1"
A$(MSG3) = "Msg 2 on page 1"

So changing it to this works
A$(1) = "Msg 1 on page 1"
A$(2) = "Msg 2 on page 1"
A$(3) = "Msg 3 on page 1"

The above is only an example but still shows the error which is actually correct. 
To be exact the compiler should complain about DIM A$(MSG1) is not valid instead it compiles then gives the out of memory message.

:-)

Thanks

This is weird. A$(0) should also work, because you're not using --array-base=1, so arrays start at 0. Huh
We should investigate this further. If you can elaborate a tiny example that reproduces the bug, please, let me know.
Reply
#4
Hi
I don't believe the issue is to do with arrays at 0 but the fact I am using a variable to reference index 0.
The below example shows starting at 1 produces the same "out of memory" 

see below :- 


DIM MSG1 as UBYTE = 1
DIM MSG2 as UBYTE = 2
DIM MSG3 as UBYTE = 3
DIM A$(10)
A$(MSG1) = "Msg 1 on page 1"
A$(MSG2) = "Msg 2 on page 1"
A$(MSG3) = "Msg 2 on page 1"


print A$(1)
print A$(2)
print A$(3)

Thanks
Reply
#5
I am using
zxbc.py 1.15.0-beta20

If this helps?
I do think this was working at some point though
Reply
#6
(04-28-2021, 06:11 PM)RandomiserUsr Wrote: I am using
zxbc.py 1.15.0-beta20

If this helps?
I do think this was working at some point though

That's right. This worked in 1.14.1. It's a regression (bug).
I'll fix it. Sorry for the inconvenience.
Reply
#7
great and no inconvenience at all just thankful for the tool - let us know what version it is in :-)

Is there list of up and coming features for ZXB ?

thanks
Reply
#8
(05-02-2021, 11:24 AM)RandomiserUsr Wrote: great and no inconvenience at all just thankful for the tool - let us know what version it is in :-)

Is there list of up and coming features for ZXB ?

thanks

Please, try this version and tell me if it works Shy

http://www.boriel.com/files/zxb/zxbasic-...a26.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...beta26.zip
http://www.boriel.com/files/zxb/zxbasic-...-win32.zip
http://www.boriel.com/files/zxb/zxbasic-...x64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...cos.tar.gz
Reply
#9
(05-06-2021, 10:46 PM)boriel Wrote:
(05-02-2021, 11:24 AM)RandomiserUsr Wrote: great and no inconvenience at all just thankful for the tool - let us know what version it is in :-)

Is there list of up and coming features for ZXB ?

thanks

Please, try this version and tell me if it works Shy

http://www.boriel.com/files/zxb/zxbasic-...a26.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...beta26.zip
http://www.boriel.com/files/zxb/zxbasic-...-win32.zip
http://www.boriel.com/files/zxb/zxbasic-...x64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...cos.tar.gz

Yes this fixes the issue ! :-)
Is there list of up and coming features for ZXB ?
Reply
#10
(05-07-2021, 04:24 PM)RandomiserUsr Wrote:
(05-06-2021, 10:46 PM)boriel Wrote:
(05-02-2021, 11:24 AM)RandomiserUsr Wrote: great and no inconvenience at all just thankful for the tool - let us know what version it is in :-)

Is there list of up and coming features for ZXB ?

thanks

Please, try this version and tell me if it works Shy

http://www.boriel.com/files/zxb/zxbasic-...a26.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...beta26.zip
http://www.boriel.com/files/zxb/zxbasic-...-win32.zip
http://www.boriel.com/files/zxb/zxbasic-...x64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...cos.tar.gz

Yes this fixes the issue ! :-)
Is there list of up and coming features for ZXB ?

I will publish them in the Changelog.md file when released (you can also have a look at the github log but it might be a bit confusing...). The most important up to the moment are:
 - Better code generation (faster and smaller, and still more to come)
 - Fixes many bugs (ok, this one included, but this was a bug introduced due to this big change)
 - Variables can now have '_' character. So _a_variable is allowed. Also _ or __.
 - Config files. You can save your options in config file and load them (i.e. project.ini by default). See --save-config in the help

I still need some extra time to finish some implementations, and that's all.
Reply
#11
(05-08-2021, 06:48 AM)boriel Wrote:
(05-07-2021, 04:24 PM)RandomiserUsr Wrote:
(05-06-2021, 10:46 PM)boriel Wrote:
(05-02-2021, 11:24 AM)RandomiserUsr Wrote: great and no inconvenience at all just thankful for the tool - let us know what version it is in :-)

Is there list of up and coming features for ZXB ?

thanks

Please, try this version and tell me if it works Shy

http://www.boriel.com/files/zxb/zxbasic-...a26.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...beta26.zip
http://www.boriel.com/files/zxb/zxbasic-...-win32.zip
http://www.boriel.com/files/zxb/zxbasic-...x64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...cos.tar.gz

Yes this fixes the issue ! :-)
Is there list of up and coming features for ZXB ?

I will publish them in the Changelog.md file when released (you can also have a look at the github log but it might be a bit confusing...). The most important up to the moment are:
 - Better code generation (faster and smaller, and still more to come)
 - Fixes many bugs (ok, this one included, but this was a bug introduced due to this big change)
 - Variables can now have '_' character. So _a_variable is allowed. Also _ or __.
 - Config files. You can save your options in config file and load them (i.e. project.ini by default). See --save-config in the help

I still need some extra time to finish some implementations, and that's all.
thanks for the above information :-) I am fine with github/lab logs so will check them out 
Thank you for continuing this brilliant project that brings joy to a lot of people
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)