Sha256: 762fa07f85349efdca8c9df7130d277e6e99d06d5d6a73d609e6984cd547746a

Contents?: true

Size: 967 Bytes

Versions: 22

Compression:

Stored size: 967 Bytes

Contents

require 'libuv'


describe Libuv::Listener do
	it "should ensure there are no remaining object references in callbacks", network: true do
		require 'objspace'

		checked = []

		# These are created by loop objects and are never cleaned up
		# This is OK as the loops are expected to execute for the life of the application
		except = [::Libuv::Async, ::Libuv::Timer, ::Libuv::Prepare, ::Libuv::Signal]

		ObjectSpace.each_object(Class) do |cls|
			next unless cls.ancestors.include? ::Libuv::Handle
			next if checked.include? cls
			checked << cls

			values = cls.callback_lookup.values
			values.select! {|val| except.include?(val.class) ? false : val.class }

			if values.length > 0
				puts "\nMemory Leak in #{cls} with #{values.length} left over objects"
				puts "Checked #{checked.length} classes, objects are:"
				values.each do |val|
					puts "\n#{val}\n"
				end
				raise 'Free the machines!'
			end
		end

		expect(checked.length).to be > 3
	end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
libuv-4.0.9 spec/zen_spec.rb
libuv-4.0.2 spec/zen_spec.rb
libuv-4.0.1 spec/zen_spec.rb
libuv-4.0.0 spec/zen_spec.rb
libuv-3.3.0 spec/zen_spec.rb
libuv-3.2.4 spec/zen_spec.rb
libuv-3.2.3 spec/zen_spec.rb
libuv-3.2.2 spec/zen_spec.rb
libuv-3.2.1 spec/zen_spec.rb
libuv-3.2.0 spec/zen_spec.rb
libuv-3.1.9 spec/zen_spec.rb
libuv-3.1.8 spec/zen_spec.rb
libuv-3.1.7 spec/zen_spec.rb
libuv-3.1.6 spec/zen_spec.rb
libuv-3.1.5 spec/zen_spec.rb
libuv-3.1.4 spec/zen_spec.rb
libuv-3.1.3 spec/zen_spec.rb
libuv-3.1.2 spec/zen_spec.rb
libuv-3.1.1 spec/zen_spec.rb
libuv-3.1.0 spec/zen_spec.rb