Announcement

Collapse
No announcement yet.

Problem (and solution) for Graphic Font

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem (and solution) for Graphic Font

    I wanted to pass along a solution provided by the PB staff to me for a problem I was having with the Graphic Font command.

    My program was crashing after running for a time, with performance slowing before the crash.

    In several subroutines, I was drawing to a graphic screen, and changing the font within each subroutine to a different font as here:

    SUB zoomtext
    Graphic Font "Microsoft Sans Serif", 10
    draw stuff....
    END SUB

    By monitoring the process size in the windows task manager, the memory required of the program almost doubled before it crashed. Something to do with how memory is allocated with the "Graphic Font" command.

    PB recommended changing to use their recommended FONT handling as in:

    FUNCTION PBMAIN() AS LONG
    ....
    GLOBAL mss10 as LONG
    FONT NEW "Microsoft Sans Serif", 10 TO mss10
    ...
    END FUNCTION

    SUB zoomtext
    GRAPHIC SET FONT mss10
    draw stuff....
    END SUB

    It also worked just fine to use the "FONT NEW" command inside the SUB each time it is called, if you don't want any GLOBAL variables.

    No more crashes and the speed of execution noticeably faster. Thanks PB!
Working...
X