[comp.sys.amiga.tech] Trouble with ADOS 1.3 and Fonts

BAXTER_A@wehi.dn.mu.oz (09/27/90)

While I'm at it, this one has had me worried for _AGES_.

In my program, I open a font. I close it and quit. Memory counter drops
a bit. No deal. Flush fonts. No memory loss. Fair enough. After I run
the program, the font sits in memory, and takes up space. It is available
for use if I want to open the font again.

I run my program, quit. Counter goes down, Run it again, counter
goes down again by the same amount. The counter goes down by the same amount
_every_ time I run the program. Flush fonts, all memory back again.
SO: each time I run the program, I get a _new_ copy of the font in memory.
This copy doesn't come from disk (no access), it is copied from one
part of memory to another. 

I checked this out with Xoper. Sure enough, every time I run the program,
a new font is created in memory, exactly the same size and specs as the
others, and after quitting they all have 0 processes using then on the 
counter.

This is pretty bad, but when you consider that my program opens _four_
fonts, it is getting rediculous.

QUESTIONS: Is this a bug? Is there a special way of asking for fonts that
actually lets you use the one already there? Is there any salvation in
2.0?

Regards Alan

forgeas@swinjm.UUCP (Jean-Michel Forgeas) (09/28/90)

In article <13387@wehi.dn.mu.oz>, BAXTER_A@wehi.dn.mu.oz writes:

> While I'm at it, this one has had me worried for _AGES_.
>
> In my program, I open a font. I close it and quit. Memory counter drops
> a bit. No deal. Flush fonts. No memory loss. Fair enough. After I run
> the program, the font sits in memory, and takes up space.
> [...]
> SO: each time I run the program, I get a _new_ copy of the font in memory.

Are you opening the font with OpenDiskFont() ? This function does not
look for previously loaded fonts in memory, but reload them from disk
every time it is called.

> This copy doesn't come from disk (no access), it is copied from one
> part of memory to another.

Perhaps you do not see any disk access because you are using AddBuffers,
FaccII, DiskSpeed, or a like ?

> QUESTIONS: Is this a bug? Is there a special way of asking for fonts that
> actually lets you use the one already there? Is there any salvation in
> 2.0?

I had a problem like that and found the solution into a C= documentation
(don't remember which one, perhaps AmigaMail), here it is:

- Do an OpenFont() to get the previously loaded font in memory
- If successfull, compare the Y size obtained with the one you really
  want, because if you ask Times15 and there is Times24 in memory,
  OpenFont will succes with Times24.
- So if you did not get what you want do an OpenDiskFont()

With this method, the opened font stays in memory, but every time you
run your program it will find it so will not reload it.

> Regards Alan
--
                                     \___/
Jean-Michel Forgeas                   \-/
cbmvax!cbmehq!cbmfra!swinjm!forgeas    |    The Software Winery
                                      -^-
                           And, where is the universe ?

peterk@cbmger.UUCP (Peter Kittel GERMANY) (10/01/90)

In article <17f70f12.ARN01888@swinjm.UUCP> forgeas@swinjm.UUCP (Jean-Michel Forgeas) writes:
>In article <13387@wehi.dn.mu.oz>, BAXTER_A@wehi.dn.mu.oz writes:
>>
>> In my program, I open a font. I close it and quit. Memory counter drops
                                   ^^^^^ REALLY?
>> a bit. No deal. Flush fonts. No memory loss. Fair enough. After I run
>> the program, the font sits in memory, and takes up space.
>> [...]
>> SO: each time I run the program, I get a _new_ copy of the font in memory.
>
>Are you opening the font with OpenDiskFont() ? This function does not
>look for previously loaded fonts in memory, but reload them from disk
>every time it is called.

Can't be. Yes I'm lazy, and I've done a demo running for DAYS and I'm
permanently swapping fonts, topaz, diamond and an own one. First,
I CloseFont the actual one, then I OpenDiskFont the next one.
No problems with memory, I get it all back. What do you differently?

>- Do an OpenFont() to get the previously loaded font in memory
>- If successfull, compare the Y size obtained with the one you really
>  want, because if you ask Times15 and there is Times24 in memory,
>  OpenFont will succes with Times24.
>- So if you did not get what you want do an OpenDiskFont()
>
>With this method, the opened font stays in memory, but every time you
>run your program it will find it so will not reload it.

But after your own theory, you still wouldn't be able to get rid of
the old version?

-- 
Best regards, Dr. Peter Kittel  // E-Mail to  \\  Only my personal opinions... 
Commodore Frankfurt, Germany  \X/ {uunet|pyramid|rutgers}!cbmvax!cbmger!peterk

forgeas@swinjm.UUCP (Jean-Michel Forgeas) (10/02/90)

In article <461@cbmger.UUCP>, Peter Kittel GERMANY writes:

> In article <17f70f12.ARN01888@swinjm.UUCP> forgeas@swinjm.UUCP (Jean-Michel Forgeas) writes:
> >In article <13387@wehi.dn.mu.oz>, BAXTER_A@wehi.dn.mu.oz writes:
> >- Do an OpenFont() to get the previously loaded font in memory
> >- If successfull, compare the Y size obtained with the one you really
> >  want, because if you ask Times15 and there is Times24 in memory,
> >  OpenFont will succes with Times24.
> >- So if you did not get what you want do an OpenDiskFont()
> >
> >With this method, the opened font stays in memory, but every time you
> >run your program it will find it so will not reload it.
>
> But after your own theory, you still wouldn't be able to get rid of
> the old version?

From the RKM (perhaps too old to be valid ? RKM 1.0, page 2-210 Text):
"Even though you close a font, it doesn't get unloaded Memory unless a
font with a different name is specified for loading. In this case, any
font (except the topaz set) which has been closed can have its memory
area freed and it will no longer be accessible. If you close a font to
go to a different point-size, it will NOT cause a disk-access"

So effectively I can't get rid of the old version. But as soon as a
program loads an other font (like your demo) the old one is unloaded
if its accessor count is zero.

> Best regards, Dr. Peter Kittel  // E-Mail to  \\  Only my personal opinions...

Best regards, Jean-Michel
--
                                     \___/
Jean-Michel Forgeas                   \-/
cbmvax!cbmehq!cbmfra!swinjm!forgeas    |    The Software Winery
                                      -^-
                           And, where is the universe ?

BAXTER_A@wehi.dn.mu.oz (10/02/90)

In article <17f70f12.ARN01888@swinjm.UUCP>, forgeas@swinjm.UUCP (Jean-Michel Forgeas) writes:
> In article <13387@wehi.dn.mu.oz>, BAXTER_A@wehi.dn.mu.oz writes:
> 
>> While I'm at it, this one has had me worried for _AGES_.
>>
>> In my program, I open a font. I close it and quit. Memory counter drops
>> a bit. No deal. Flush fonts. No memory loss. Fair enough. After I run
>> the program, the font sits in memory, and takes up space.
>> [...]
>> SO: each time I run the program, I get a _new_ copy of the font in memory.
> 
> Are you opening the font with OpenDiskFont() ? This function does not
> look for previously loaded fonts in memory, but reload them from disk
> every time it is called.

Yes. That's not what my autodocs say.

> 
>> This copy doesn't come from disk (no access), it is copied from one
>> part of memory to another.
> 
> Perhaps you do not see any disk access because you are using AddBuffers,
> FaccII, DiskSpeed, or a like ?
> 

Perhaps

>> QUESTIONS: Is this a bug? Is there a special way of asking for fonts that
>> actually lets you use the one already there? Is there any salvation in
>> 2.0?
> 
> I had a problem like that and found the solution into a C= documentation
> (don't remember which one, perhaps AmigaMail), here it is:
> 
> - Do an OpenFont() to get the previously loaded font in memory
> - If successfull, compare the Y size obtained with the one you really
>   want, because if you ask Times15 and there is Times24 in memory,
>   OpenFont will succes with Times24.
> - So if you did not get what you want do an OpenDiskFont()
> 
> With this method, the opened font stays in memory, but every time you
> run your program it will find it so will not reload it.

That's more or less what I ended up with. My main problem was the use
of a font for menus/screen default. That did not work at all well unless
I did as you suggest first, then open the screen, not use the font, but
let the system find it in memory when it does screen bars/menus, close 
the screen when finished, and then close the font.

Regards Alan