Module: Lich::Util::MemoryReleaser
- Defined in:
- documented/util/memoryreleaser.rb
Overview
Memory management module that provides automatic and manual memory release functionality Memory management module that provides automatic and manual memory release functionality
Defined Under Namespace
Classes: Manager
Constant Summary collapse
- DEFAULT_SETTINGS =
Default settings for memory releaser Default settings for memory releaser
{ auto_start: false, # Disabled by default, user must enable interval: 900, # default of 15 minutes verbose: false, }.freeze
Class Attribute Summary collapse
-
.command_queue ⇒ Object
readonly
Returns the value of attribute command_queue.
-
.worker_thread ⇒ Object
readonly
Returns the value of attribute worker_thread.
Class Method Summary collapse
-
.auto_disable! ⇒ Boolean
Disables auto-start for the memory releaser using the singleton instance.
-
.auto_start! ⇒ Boolean
Enables auto-start for the memory releaser using the singleton instance.
-
.benchmark ⇒ void
Runs a benchmark to show memory usage before and after release using the singleton instance.
-
.instance ⇒ Manager
Retrieves the singleton instance of the MemoryReleaser.
-
.interval!(seconds) ⇒ Integer
Sets the interval for memory release using the singleton instance.
-
.release ⇒ void
Releases memory using the singleton instance.
- .reset! ⇒ Object
-
.running? ⇒ Boolean
Checks if the memory releaser worker is currently running using the singleton instance.
-
.start(interval: nil, verbose: nil) ⇒ Thread?
Starts the memory releaser worker using the singleton instance.
-
.status ⇒ Hash
Retrieves the current status of the memory releaser using the singleton instance.
-
.stop ⇒ void
Stops the memory releaser worker using the singleton instance.
-
.verbose!(enabled) ⇒ Boolean
Sets the verbose mode for logging using the singleton instance.
Class Attribute Details
.command_queue ⇒ Object (readonly)
Returns the value of attribute command_queue.
529 530 531 |
# File 'documented/util/memoryreleaser.rb', line 529 def command_queue @command_queue end |
.worker_thread ⇒ Object (readonly)
Returns the value of attribute worker_thread.
531 532 533 |
# File 'documented/util/memoryreleaser.rb', line 531 def worker_thread @worker_thread end |
Class Method Details
.auto_disable! ⇒ Boolean
Disables auto-start for the memory releaser using the singleton instance
573 574 575 |
# File 'documented/util/memoryreleaser.rb', line 573 def auto_disable! instance.auto_disable! end |
.auto_start! ⇒ Boolean
Enables auto-start for the memory releaser using the singleton instance
567 568 569 |
# File 'documented/util/memoryreleaser.rb', line 567 def auto_start! instance.auto_start! end |
.benchmark ⇒ void
This method returns an undefined value.
Runs a benchmark to show memory usage before and after release using the singleton instance
611 612 613 |
# File 'documented/util/memoryreleaser.rb', line 611 def benchmark instance.benchmark end |
.instance ⇒ Manager
Retrieves the singleton instance of the MemoryReleaser
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
# File 'documented/util/memoryreleaser.rb', line 535 def instance @mutex ||= Mutex.new @mutex.synchronize { @instance ||= begin manager = Manager.new # Auto-start if enabled in settings if manager.settings[:auto_start] manager.start end manager end } end |
.interval!(seconds) ⇒ Integer
Sets the interval for memory release using the singleton instance
580 581 582 |
# File 'documented/util/memoryreleaser.rb', line 580 def interval!(seconds) instance.interval!(seconds) end |
.release ⇒ void
This method returns an undefined value.
Releases memory using the singleton instance
593 594 595 |
# File 'documented/util/memoryreleaser.rb', line 593 def release instance.release end |
.reset! ⇒ Object
615 616 617 618 |
# File 'documented/util/memoryreleaser.rb', line 615 def reset! @instance&.stop @instance = nil end |
.running? ⇒ Boolean
Checks if the memory releaser worker is currently running using the singleton instance
599 600 601 |
# File 'documented/util/memoryreleaser.rb', line 599 def running? instance.running? end |
.start(interval: nil, verbose: nil) ⇒ Thread?
Starts the memory releaser worker using the singleton instance
555 556 557 |
# File 'documented/util/memoryreleaser.rb', line 555 def start(interval: nil, verbose: nil) instance.start(interval: interval, verbose: verbose) end |
.status ⇒ Hash
Retrieves the current status of the memory releaser using the singleton instance
605 606 607 |
# File 'documented/util/memoryreleaser.rb', line 605 def status instance.status end |
.stop ⇒ void
This method returns an undefined value.
Stops the memory releaser worker using the singleton instance
561 562 563 |
# File 'documented/util/memoryreleaser.rb', line 561 def stop instance.stop end |
.verbose!(enabled) ⇒ Boolean
Sets the verbose mode for logging using the singleton instance
587 588 589 |
# File 'documented/util/memoryreleaser.rb', line 587 def verbose!(enabled) instance.verbose!(enabled) end |