Socket
Book a DemoInstallSign in
Socket

diverter

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diverter

0.0.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

diverter

Lightweight Ruby library for executing tasks in a seperate Ruby subprocesses

Motivation

Ruby very rarely releases memory back to the operating system once allocated. This gem realizes a neat trick as suggested by the Book "Ruby Performance Optimization" by Alexander Dymo: https://pragprog.com/book/adrpo/ruby-performance-optimization

The crucial point is that exiting a subprocess will force Ruby to release all the memory allocated in the subprocess back to the OS.

Synopsis

class DecadentMemoryConsumer# Needs a lot of memory
  # to execute some magical
  # taskend

# If the predicate :memory_almost_exceeded? evaluates to true,
# the block will be executed in a forked subprocess
# that is forced to terminate afterwards
Diverter.new(condition: memory_almost_exceeded?) do
  DecadentMemoryConsumer.perform_memory_expensive_operation
end

# condition defaults to true, so this is equivalent of condition set to true
Diverter.new do
  DecadentMemoryConsumer.perform_memory_expensive_operation
end

Changelog

0.0.1

Initial version

FAQs

Package last updated on 20 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.