English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. AMOS

 
 
Thread Tools
Old 08 August 2023, 11:48   #1
Mikket
Registered User
 
Join Date: May 2019
Location: Finland
Posts: 13
AMCAF Fonts Bug?

Hi.

Have you noticed this kind of bug in Amcaf?

Text bank change seems to eat all the memory . First fast, then chip.

I have hud, where I like to use different sizes of fonts, so I change
the bank in main loop.

This problem does not exist, in some winuae configurations.
But in real Amiga 1200 + 4mb (and Winuae, with similar config) it happends.

How can it be avoided?


Here's code to test:

Screen Open 0,320,256,2,Lowres
Curs Off : Colour 1,$FFF
Make Bank Font 7
Change Font "ruby.font",8
Make Bank Font 8

Repeat
Change Bank Font 7
Text 10,10,"Chip:"+Str$(Chip Free)+" "
Change Bank Font 8
Text 10,20,"Fast:"+Str$(Fast Free)+" "
Until Mouse Click
Mikket is offline  
Old 24 August 2023, 14:47   #2
adrazar
Registered User
 
Join Date: Feb 2017
Location: Oslo
Posts: 91
Hey, it's leaking my memory too!

Like you I am using Change Bank Font frequently in the project I'm currently working on, so this problem is relevant for me as well.
Incredible find @Mikket
adrazar is offline  
Old 24 August 2023, 15:30   #3
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,824
No idea but what is you Erase 7 etc or Erase All etc does it make a difference?
Retro1234 is offline  
Old 24 August 2023, 19:21   #4
adrazar
Registered User
 
Join Date: Feb 2017
Location: Oslo
Posts: 91
Lucky me! I found a way to plug the leak

Quote:
Originally Posted by Retro1234 View Post
No idea but what is you Erase 7 etc or Erase All etc does it make a difference?
No, not this (it increased the chip ram, but fast ram did not come back)

I went over to the SetFont docs, and found in the BUGS section that this function is known to have a memory leak problem, starting from kickstart V36 (which according to wikipedia means starting with the A500+ model). It further suggests using StripFont to solve the problem, and this appears to work.

The following instructions will call StripFont with the required arguments:
Code:
Areg(0)=Leek(Scrn Rastport+52) : RESULT=Gfxcall(-822)
I found that it works to insert this code right after each call to Change Bank Font.
adrazar is offline  
Old 24 August 2023, 21:48   #5
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,824
Retro1234 is offline  
Old 28 August 2023, 23:12   #6
Mikket
Registered User
 
Join Date: May 2019
Location: Finland
Posts: 13
Great, that you found this fix adrazar. I had to transfer one font to icons, but now i can change back to amcaf font bank. Thanks.
Mikket is offline  
Old Yesterday, 19:00   #7
adrazar
Registered User
 
Join Date: Feb 2017
Location: Oslo
Posts: 91
Quote:
Originally Posted by adrazar View Post
I found that it works to insert this code right after each call to Change Bank Font.
After (finally) testing this for real, in the real application, I'm doubting this is the right way to do it... It frees the memory all right, but it apparently also makes the font unusable. So I have a new prevailing theory, which is that the right time to call StripFont must be, not just after, but just before calling Change Bank Font.

Another thing I found while testing is that if the same bank font is used in two different screens at the same time, then StripFont can restore the memory for only one of them. So to avoid memory leak, one must see to it that two screens never share the same bank font. Achieving this turns out to be a bit tricky, but I've nevertheless managed to concoct a strategy which I'm reasonably satisfied with: First, for simplicity I try to invariantly make it so that at all times at most one screen has a bank font assigned to it (this was already more or less the case in my program). Second, to return to the default amos font I created this procedure:

Code:
AMOSFONT=Leek(Scrn Rastport+52)
Global AMOSFONT

Procedure RESETFONT
   ' Avoid calling StripFont on the default font
   If Leek(Scrn Rastport+52)=AMOSFONT Then Pop Proc

   ' Call StripFont
   Areg(0)=Leek(Scrn Rastport+52)
   RESULT=Gfxcall(-822)

   ' Restore the default font
   Loke Scrn Rastport+52,AMOSFONT
   Doke Scrn Rastport+62,6 : Rem <- value returned by Text Base
End Proc
The last part, which restores the default font, could be expanded to assign further font-related rastport values, but so far these two values has proven to be sufficient.

Last edited by adrazar; Yesterday at 23:59.
adrazar is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Fonts Using AMCAF DrkStarr Coders. AMOS 8 17 July 2023 15:04
WinUae 4.4.0 - Action replay bug/ Load Config bug Dan support.WinUAE 2 20 July 2020 07:59
Bug in x64 file requester and bug in Blizzard PPC ROM filesize headkase support.WinUAE 5 26 June 2016 14:17
Fonts GordonM support.WinUAE 8 04 May 2016 18:20
Fonts alkis21 request.Apps 2 23 August 2002 09:33

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:01.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.12142 seconds with 15 queries