Random Homebrew: Bookr plugin for iR Shell
shell program that allows you to view PDF and TXT files using a modified version of the popular home [...]
Friends: Coding 'n Cracking - Nymphaea - PS3 Forum - darkforestgroup - daxhordes.org - Tgames - coldbird - gopsp.it - pspstation.org - prometheus - hgoel.info - MakeSmartTV - ps vita

[LUA] Unloading an image and font?

Forum rules
Any post not directly related to programming will be moderated.
Do not request people to code something for you.
Avoid posting messages that do not bring anything to the conversation. We want the threads in this subforum to stay focused.

Re: [LUA] Unloading an image and font?

Postby Zasisem » Fri Nov 25, 2011 6:02 pm

enamo wrote:It is a interesting sharing......

What is?
Zasisem
 
Posts: 281
Joined: Mon Sep 27, 2010 3:49 pm

Re: [LUA] Unloading an image and font?

Postby Killerfeeshy » Wed Nov 30, 2011 3:45 am

Am I right in saying that if you have already loaded a font you can replace it with another one of the same name, for example

Font1 has been previously loaded

Now you load a new font but again call it Font1

Does this overwrite the first Font1?

Thanks
70 M3 M7 P5P 15 L1K3 4 DRUG 1F I75 /\/07 I/\/ M7 P0CK37 1M G0/\//\/4 P4/\/1C

My Homebrews
Crazy Eyes
ProKill
Top Down Racing
And others currently unreleased

Got any questions? http://www.ask.fm/Killerfeeshy
Killerfeeshy
 
Posts: 357
Joined: Wed Jun 01, 2011 9:49 am

Re: [LUA] Unloading an image and font?

Postby Zasisem » Thu Dec 01, 2011 11:13 pm

Killerfeeshy wrote:Am I right in saying that if you have already loaded a font you can replace it with another one of the same name, for example

Font1 has been previously loaded

Now you load a new font but again call it Font1

Does this overwrite the first Font1?

Thanks

There's 2 ways someone can answer your question.

Answer 1
font_1 = Font.load("verdana.ttf")
font_2 = Font.load("verdana.ttf")
Notice we use the same font verdana.ttf but with different variable names. This is fine.

Answer 2
font_1 = Font.load("verdana.ttf")
font_1 = Font.load("spacefont.ttf")
The last font that was loaded spacefont will work as the variable font_1

So your answer is yes.. It will replace it :)
Zasisem
 
Posts: 281
Joined: Mon Sep 27, 2010 3:49 pm

Re: [LUA] Unloading an image and font?

Postby Killerfeeshy » Fri Dec 02, 2011 5:58 pm

Zasisem wrote:
Killerfeeshy wrote:Am I right in saying that if you have already loaded a font you can replace it with another one of the same name, for example

Font1 has been previously loaded

Now you load a new font but again call it Font1

Does this overwrite the first Font1?

Thanks

There's 2 ways someone can answer your question.

Answer 1
font_1 = Font.load("verdana.ttf")
font_2 = Font.load("verdana.ttf")
Notice we use the same font verdana.ttf but with different variable names. This is fine.

Answer 2
font_1 = Font.load("verdana.ttf")
font_1 = Font.load("spacefont.ttf")
The last font that was loaded spacefont will work as the variable font_1

So your answer is yes.. It will replace it :)

Thanks man, I was looking for answer 2 but I do that in scripts anyway :p also I should have been more specific, does answer 2 overwrite the font that's loaded in the ram, therefor using less ram (memory)
70 M3 M7 P5P 15 L1K3 4 DRUG 1F I75 /\/07 I/\/ M7 P0CK37 1M G0/\//\/4 P4/\/1C

My Homebrews
Crazy Eyes
ProKill
Top Down Racing
And others currently unreleased

Got any questions? http://www.ask.fm/Killerfeeshy
Killerfeeshy
 
Posts: 357
Joined: Wed Jun 01, 2011 9:49 am

Re: [LUA] Unloading an image and font?

Postby 10$man » Fri Dec 02, 2011 7:58 pm

I think that both fonts are still loaded, but you can't access the first of the two. Thus the command, collect.garbage() which removes unused data from memory.

I have loaded a massive amount of images into Luaplayer and had no problem with memory, so don't kill yourself over this.
10$man
 
Posts: 53
Joined: Thu Feb 03, 2011 9:18 pm

Re: [LUA] Unloading an image and font?

Postby cmbeke » Fri Dec 02, 2011 10:26 pm

The easiest way to check if it overwrites or replaces would be to use System.getFreeMemory(), then load and unload a font a couple times to see if it works.
You probably didn't know that you don't know that you don't know what you don't know.
I know I'm crazy, the real question is are you?
Life is nothing but discrimination, likes, dislikes, any choice made ... all a product of discrimination.
User avatar
cmbeke
 
Posts: 49
Joined: Tue Apr 12, 2011 9:51 pm

Re: [LUA] Unloading an image and font?

Postby Zasisem » Fri Dec 02, 2011 11:15 pm

10$man wrote:I think that both fonts are still loaded, but you can't access the first of the two.

This.
10$man wrote:I have loaded a massive amount of images into Luaplayer and had no problem with memory, so don't kill yourself over this.

So have I.

cmbeke wrote:The easiest way to check if it overwrites or replaces would be to use System.getFreeMemory(), then load and unload a font a couple times to see if it works.

It will load both.
Zasisem
 
Posts: 281
Joined: Mon Sep 27, 2010 3:49 pm

Re: [LUA] Unloading an image and font?

Postby Killerfeeshy » Sat Dec 03, 2011 7:29 pm

Thanks for the feedback peeps, I'll carry on using collect.garbage() as I've been doing then

Thanks ;)
70 M3 M7 P5P 15 L1K3 4 DRUG 1F I75 /\/07 I/\/ M7 P0CK37 1M G0/\//\/4 P4/\/1C

My Homebrews
Crazy Eyes
ProKill
Top Down Racing
And others currently unreleased

Got any questions? http://www.ask.fm/Killerfeeshy
Killerfeeshy
 
Posts: 357
Joined: Wed Jun 01, 2011 9:49 am

Previous

Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests