ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   LUA Memory Limit (https://www.esoui.com/forums/showthread.php?t=2067)

Sasky 08/06/14 10:50 AM

LUA Memory Limit
 
Someone in my guild ran a diff of UserSettings.txt and noticed there is now a line for LUA memory limit:

Code:

SET LuaMemoryLimitMB "64"
Has anyone run into any issues yet or seen how close to the limit they're running?

For a rough estimate, my personal SavedVars folder is running around 10.5MB and 14MB in the addons folder. Most data-heavy addons seem to either pre-define the data (map pins) or pull and store the data in SavedVars (inventory, character info, guildmate info), so adding those would be a decent estimate.

EDIT: For an actual count, you can use this (or a variation):
Lua Code:
  1. /script d(math.ceil(collectgarbage("count")).." KB")

Garkin 08/06/14 10:56 AM

My saved variables folder is 52.4MB (the biggest is PriceTracker.lua with 34.1MB) and no error so far.

By the way there is a new event:
EVENT_LUA_LOW_MEMORY

and when it occurs, it shows this error message:
"Lua is reaching its memory limit. You should consider disabling some addons and reloading the UI."

Deome 08/06/14 01:08 PM

Now that is very handy news to have--I'm always worrying about memory.

Especially the event. Now I can use the event to add a function that provides players with a little more information, like "Hey, take a screenshot and post this in a bug report for DD! I want to know if you see this!"

Harbonah 08/06/14 02:41 PM

Quote:

Originally Posted by Garkin (Post 11203)
My saved variables folder is 52.4MB (the biggest is PriceTracker.lua with 34.1MB) and no error so far.

Just for information :)

Addon folder 33MB (96 addon)
Savedvariables folder 24MB

On main char ~85 addon active, no error
On alts ~85 addon active, always get the error
On mules 40-50 addon active, no error

Seerah 08/06/14 07:56 PM

o.O In WoW, it's not unheard of to have memory usage of over 150MB.

mctaylor 08/06/14 08:26 PM

Quote:

Originally Posted by Garkin (Post 11203)
[...]
new event: EVENT_LUA_LOW_MEMORY

and when it occurs, it shows this error message:
"Lua is reaching its memory limit. You should consider disabling some addons and reloading the UI."

I'm assuming even well-behaved add-ons aren't expected to listen and effectively reaction to this event?

With Lua's garbage collection, can you free much memory usage from within an add-on? Free up a few tables by setting them to nil? Set any textures to nil or unload otherwise free them?

I don't know if an add-on can disable or free itself.

I guess you can un-register for events, or even set functions to nil but I don't thing that's enough to kill an add-on in memory. (Functions being a first-class data type / object)

Not intended to be dismissive of Lua or the versatility of automatic GC. Just surprised to see it, but I'd guess its visible unintentionally because it is part of the Add-on API / support.

Rainith 08/06/14 10:25 PM

So I'm getting this every time I log in, can I change the setting in the UserSettings file to a bigger number to make it go away? If so is there some sort of upper limit number that I shouldn't set it above? :confused:

katkat42 08/06/14 10:40 PM

Quote:

Originally Posted by Rainith (Post 11239)
So I'm getting this every time I log in, can I change the setting in the UserSettings file to a bigger number to make it go away?

It seems likely, and worth a try if you're getting errors.

Quote:

If so is there some sort of upper limit number that I shouldn't set it above? :confused:
I imagine that varies with the power of your computer. If you've got lots of RAM to spare and don't run a lot of stuff in the background, you probably have a lot of leeway. But if it were me, I would probably stick to powers of 2 (ie, 128, 256...).

Sasky 08/07/14 02:56 AM

Quote:

Originally Posted by Rainith (Post 11239)
So I'm getting this every time I log in, can I change the setting in the UserSettings file to a bigger number to make it go away? If so is there some sort of upper limit number that I shouldn't set it above? :confused:

Yeah, it depends on how much system memory you have. You probably don't want to push it to say the 4GB range if you have 8GB of RAM.

Also, how many addons are you running? This could just be because you use a lot of addons (which adds up) or could be from a couple that just use a lot of RAM.

PS: To see how much RAM you're actually using, you can enter this command in the chatbox:
Lua Code:
  1. /script d(math.ceil(collectgarbage("count")).." KB")

Rainith 08/08/14 08:22 PM

Just as a follow up, I checked and I'm currently using about 74 megs, so 10 or so over the default limit. I went ahead and edited that line in the UserSettings file and doubled it to 128. It stopped the message popup every time I logged in or reloaded the ui. Nothing negative noticed as of yet.

Sasky 08/09/14 11:28 AM

Quote:

Originally Posted by Rainith (Post 11311)
Just as a follow up, I checked and I'm currently using about 74 megs, so 10 or so over the default limit. I went ahead and edited that line in the UserSettings file and doubled it to 128. It stopped the message popup every time I logged in or reloaded the ui. Nothing negative noticed as of yet.

You probably won't unless you force the system to go to page swap. That will probably only occur if an addon has a memory leak. In fact, I'd bet they put this in to cover their bases and make sure addons aren't causing memory leaks. (Even though you have to have rather bad design to do in a language like LUA, since it does automatic garbage collection.)

zgrssd 08/09/14 05:11 PM

Quote:

Originally Posted by mctaylor (Post 11234)
I'm assuming even well-behaved add-ons aren't expected to listen and effectively reaction to this event?

With Lua's garbage collection, can you free much memory usage from within an add-on? Free up a few tables by setting them to nil? Set any textures to nil or unload otherwise free them?

The best you can do for memory management is to use weak table references where appropirate (cachign scenarios):
http://www.lua.org/pil/17.html

That way the GC can decide to throw it out when it needs memory, but it stays around if no collection is neesesary.
And generally the GC should have tried to collect everything possible before it runs into a OOM exception.
The most reliable way to use a weak reference is to assign it's value to a local variable.
If the item was already collected, you get nil. If not, you now have a strong reference (for the duration of your code).

I used a weak reference table for the cache in LibConstantMapper. If the GC needs the memory, it can collect it any time. If not, it keeps the calls up to speed.

zgrssd 08/09/14 05:20 PM

Quote:

Originally Posted by Sasky (Post 11247)
Yeah, it depends on how much system memory you have. You probably don't want to push it to say the 4GB range if you have 8GB of RAM.

Note quite true. The game itself is still a 32 bit application so it cannot use more the 4 GiB memory, regardless how much the computer has.
This lua memory limit (propably) only says how much of those 4 GiB can be taken up by Lua (and thus addons).
If you set it too high, addons might take too much memory and then there is not enough for the graphics and game left (so game OOM exception might become more common). Raise it carefully and ideally by multiplying the original value by 2.

TotterTates 08/18/14 08:33 AM

Quote:

Originally Posted by zgrssd (Post 11330)
The best you can do for memory management is to use weak table references where appropirate (cachign scenarios):
http://www.lua.org/pil/17.html

That way the GC can decide to throw it out when it needs memory, but it stays around if no collection is neesesary.
And generally the GC should have tried to collect everything possible before it runs into a OOM exception.
The most reliable way to use a weak reference is to assign it's value to a local variable.
If the item was already collected, you get nil. If not, you now have a strong reference (for the duration of your code).

I used a weak reference table for the cache in LibConstantMapper. If the GC needs the memory, it can collect it any time. If not, it keeps the calls up to speed.

I can build a computer and customize pieces of hardware like nobody's business, but when it comes to writing code I'm completely lost. Could I trouble you to assist with adding these tables to my files?

recreare 12/18/14 12:52 AM

I set my LUA memory from 64 to 128 as I saw here, and I save the file, but it seems to keep setting itself back to 64. Any similar experiences/suggestions?

igerup 12/18/14 04:15 AM

Don't forget to set the file properties to read only after you've made the changes you want.

Garkin 12/18/14 06:47 AM

Quote:

Originally Posted by recreare (Post 17908)
I set my LUA memory from 64 to 128 as I saw here, and I save the file, but it seems to keep setting itself back to 64. Any similar experiences/suggestions?

If you want to make changes to the UserSettings.txt, you have to do it when game is not running.

It's because game reads settings from the file only during the startup. But settings are saved from memory to the file everytime when you logout to the character selection screen, to the account login and finally when game is closed. In other words if you've made any changes to the settings when game is running, it will be automatically overwritten with the settings currently in use.

If you want to change Lua memory limit value when game is running, type the following command to the chat:
Code:

/script SetCVar("LuaMemoryLimitMB", "128")


Quote:

Originally Posted by igerup (Post 17915)
Don't forget to set the file properties to read only after you've made the changes you want.

I do not recommend making UserSettings.txt read only.


All times are GMT -6. The time now is 12:56 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI