mirror of
https://github.com/evennia/evennia.git
synced 2026-04-02 14:07:16 +02:00
Added /flushmem switch to the server command to incur the idmapper flushing.
This commit is contained in:
parent
e7e50039d7
commit
4b8ed234fd
3 changed files with 20 additions and 5 deletions
|
|
@ -624,9 +624,11 @@ class CmdServerLoad(MuxCommand):
|
|||
|
||||
Switch:
|
||||
mem - return only a string of the current memory usage
|
||||
flushmem - flush the idmapper cache
|
||||
|
||||
This command shows server load statistics and dynamic memory
|
||||
usage.
|
||||
usage. It also allows to flush the cache of accessed database
|
||||
objects.
|
||||
|
||||
Some Important statistics in the table:
|
||||
|
||||
|
|
@ -641,9 +643,12 @@ class CmdServerLoad(MuxCommand):
|
|||
loaded by use of the idmapper functionality. This allows Evennia
|
||||
to maintain the same instances of an entity and allowing
|
||||
non-persistent storage schemes. The total amount of cached objects
|
||||
are displayed plus a breakdown of database object types. Finally,
|
||||
{wAttributes{n are cached on-demand for speed. The total amount of
|
||||
memory used for this type of cache is also displayed.
|
||||
are displayed plus a breakdown of database object types.
|
||||
|
||||
The {wflushmem{n switch allows to flush the object cache. Please
|
||||
note that due to how Python's memory management works, releasing
|
||||
caches may not show you a lower Residual/Virtual memory footprint,
|
||||
the released memory will instead be re-used by the program.
|
||||
|
||||
"""
|
||||
key = "@server"
|
||||
|
|
@ -681,6 +686,9 @@ class CmdServerLoad(MuxCommand):
|
|||
if "mem" in self.switches:
|
||||
caller.msg("Memory usage: RMEM: {w%g{n MB (%g%%), VMEM (res+swap+cache): {w%g{n MB." % (rmem, pmem, vmem))
|
||||
return
|
||||
if "flushmem" in self.switches:
|
||||
caller.msg("Flushed object idmapper cache. Python garbage collector recovered memory from %i objects." % _idmapper.flush_cache())
|
||||
return
|
||||
|
||||
# load table
|
||||
loadtable = prettytable.PrettyTable(["property", "statistic"])
|
||||
|
|
|
|||
|
|
@ -81,6 +81,13 @@ class ScriptHandler(object):
|
|||
num += script.start()
|
||||
return num
|
||||
|
||||
def get(self, scriptid):
|
||||
"""
|
||||
Return one or all scripts on this object matching scriptid. Will return
|
||||
a list.
|
||||
"""
|
||||
return ScriptDB.objects.get_all_scripts_on_obj(self.obj, key=scriptid)
|
||||
|
||||
def delete(self, scriptid=None):
|
||||
"""
|
||||
Forcibly delete a script from this object.
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ def flush_cache(**kwargs):
|
|||
for cls in class_hierarchy([SharedMemoryModel]):
|
||||
cls.flush_instance_cache()
|
||||
# run the python garbage collector
|
||||
gc.collect()
|
||||
return gc.collect()
|
||||
#request_finished.connect(flush_cache)
|
||||
post_syncdb.connect(flush_cache)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue