Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to reduce RAM usage #51

Open
wants to merge 5 commits into
base: next
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/anemone/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Core
DEFAULT_OPTS = {
# run 4 Tentacle threads to fetch pages
:threads => 4,
# Prevent page_queue from using excessive RAM. Can indirectly limit rate of crawling. You'll additionally want to use discard_page_bodies and/or a non-memory 'storage' option
:max_page_queue_size => 100,
# disable verbose output
:verbose => false,
# don't throw away the page response body after scanning it for links
Expand Down Expand Up @@ -152,7 +154,7 @@ def run
return if @urls.empty?

link_queue = Queue.new
page_queue = Queue.new
page_queue = SizedQueue.new(@opts[:max_page_queue_size])

@opts[:threads].times do
@tentacles << Thread.new { Tentacle.new(link_queue, page_queue, @opts).run }
Expand Down