|
OpenLayer font loading uses lots of memory |
Vasco Freitas
Member #6,904
February 2006
|
Just this line of code: Is taking up about 30MB of memory, and it's a pretty simple font. Is this normal? What can I do about it? |
Ceagon Xylas
Member #5,495
February 2005
|
I don't think this'd have much to do with it, but what font is it? |
Vasco Freitas
Member #6,904
February 2006
|
Just some font I got at dafont.com (I don't remember the name), but this seems to happen with all fonts, I tried 4 different fonts. The more complex the font though, the more memory it seems to use. But even the simplest ones I tried occupy 20-30MB. I'd really appreciate some help on this, the game I'm making isn't supposed to take up more than 32MB |
tobing
Member #5,213
November 2004
|
Which version of OpenLayer do you use? Compiled with which compiler? Do you use internal text rendering or GlyphKeeper? |
Vasco Freitas
Member #6,904
February 2006
|
I have a WIP version from about 5-8 months ago (after a certain version globally defined bitmaps stopped appearing, so I've stopped updating since). The compiler is gcc 3.4.2 (mingw-special). I guess I use internal text rendering, because I don't define a GlyphKeeper type. |
tobing
Member #5,213
November 2004
|
I don't know much about the state of OL of that time... I can only suggest you try to use the current SVN with the most recent allegroGL, and compile OL with define USE_NEW_TTF set, so the internal text renderer will be used instead of GlyphKeeper. That's at least what I do, and I have just checked that my memory consumption grows by about 600kB when I load a TextRenderer object. I have built with MSVC 7.1, but that should not make such a huge difference. For the problem of globally defined bitmaps disappearing, that's somewhat strange and if it occurs with the current SVN I could try to help finding what's wrong there. |
Paul whoknows
Member #5,081
September 2004
|
Quote: Is taking up about 30MB of memory... How do you know that? how can you measure it? ____ "The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner. |
Vasco Freitas
Member #6,904
February 2006
|
I compare the amount of memory the process uses with and without the font loaded, in the Windows Task Manager. I know that's probably not the best way to do it, but in this case the problem seems obvious. |
Druss
Member #7,075
March 2006
|
I don't know open layer, but could it perhaps be rendering the font to a bitmap, and so needing to store the rendered font and if the font has a lot of characters (excess unicode pages?) or rendered at large size then that might explain it. |
Vasco Freitas
Member #6,904
February 2006
|
Well, I don't know how OpenLayer stores the font, I don't load the fonts too big in size (55 pixels height), so there's no reason to save them bigger. It's surely not excess unicode pages, they usually don't have many characters. I even tried one font file that's only 9KB large. Does this happen with anyone else? |
Jonatan Hedborg
Member #4,886
July 2004
|
If you only have 32 MB of ram to play around with, i would recommend using plain allegro, or something even simpler, as that is a painfully low limit (silly really). As i understand it, the font is rendered to a texture (which is then rendered as a texture on a quad). I don't think 30MB is that unreasonable. 55 is pretty big, and the texture has to contain all the characters...
|
tobing
Member #5,213
November 2004
|
Vasco: I would offer to have a try to compile your sources on my machine, with my versions of the libraries and try it out. You don't use many other libs, I hope? If you're willing to send me sources and data, just zip them and send my a PM for my mail address. |
Vasco Freitas
Member #6,904
February 2006
|
Jonatan Hedborg: I meant 32MB of video memory. The font should be on the video memory right? (Hope I'm not saying something stupid) I think anything above 3MB is unreasonable. A 1024 x 768 image should be about 3,2MB (right?), and all letters of a font that size surely don't take all that up. tobing: Thanks for offering your help. All your need to do is run this simple code, with the font I've attached:
On my system, with the font loaded the process occupies 54.640MB, without the font loaded, 27.420MB. |
Jonatan Hedborg
Member #4,886
July 2004
|
hmm. yes, you are correct of course. My bad
|
tobing
Member #5,213
November 2004
|
Tested with your font, it also uses about 600kB extra memory... using GlyphKeeper with pure allegro, it takes 300kB extra memory... |
Vasco Freitas
Member #6,904
February 2006
|
Are you sure the font was loaded? Because, that's the extra memory I get if the font file isn't there. I tried with OpenLayer's latest update with no success. I've attached the project folder I use for the test case, with the Code::Blocks project file. I'd appreciate it if anyone could try it out. EDIT: Anybody? |
|