Skip to content

Commit b5630ce

Browse files
committed
add Object::print_all
1 parent cdf3896 commit b5630ce

File tree

5 files changed

+22
-99
lines changed

5 files changed

+22
-99
lines changed

example/example1.rb

-84
This file was deleted.

example/example2.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
# disable the operation cache
1212
Vips::cache_set_max 0
1313

14-
n = 100
14+
n = 1
1515

1616
n.times do |i|
1717
puts ""
1818
puts "call #{i} ..."
19-
out = Vips::call "black", 200, 300
19+
out = Vips::Operation.call "black", [200, 300]
2020
if out.width != 200 or out.height != 300
2121
puts "bad image result from black"
2222
end

example/example3.rb

+9-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@
1111
# turn on debug logging
1212
# Vips.set_debug true
1313

14-
10000.times do |i|
14+
1.times do |i|
1515
puts "loop #{i} ..."
1616
im = Vips::Image.new_from_file ARGV[0]
17-
im = im.embed 100, 100, 3000, 3000, :extend => :mirror
17+
# im = im.embed 100, 100, 3000, 3000, :extend => :mirror
1818
im.write_to_file "x.v"
1919
end
20+
21+
im = nil
22+
GC.start
23+
GC.start
24+
GC.start
25+
GC.start
26+
GC.start

lib/vips.rb

+1-11
Original file line numberDiff line numberDiff line change
@@ -503,22 +503,12 @@ def to_s
503503
# don't use at_exit to call vips_shutdown, it causes problems with fork, and
504504
# in any case libvips does this for us
505505

506-
attach_function :vips_object_print_all, [], :void
507506
attach_function :vips_leak_set, [:int], :void
508507

509-
def self.showall
510-
GC.start
511-
vips_object_print_all
512-
end
513-
514508
# Turn libvips leak testing on and off. Handy for debugging ruby-vips, not
515509
# very useful for user code.
516510
def self.leak_set leak
517-
if leak
518-
vips_leak_set 1
519-
else
520-
vips_leak_set 0
521-
end
511+
vips_leak_set (leak ? 1 : 0)
522512
end
523513

524514
attach_function :vips_cache_set_max, [:int], :void

lib/vips/object.rb

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
module Vips
1010
private
1111

12+
# debugging support
13+
attach_function :vips_object_print_all, [], :void
14+
1215
# we must init these by hand, since they are usually made on first image
1316
# create
1417
attach_function :vips_band_format_get_type, [], :GType
@@ -69,6 +72,13 @@ class IntStruct < FFI::Struct
6972

7073
class Object < GObject::GObject
7174

75+
# print all active VipsObjects, with their reference counts. Handy for
76+
# debugging ruby-vips.
77+
def self.print_all
78+
GC.start
79+
vips_object_print_all
80+
end
81+
7282
# the layout of the VipsObject struct
7383
module ObjectLayout
7484
def self.included base

0 commit comments

Comments
 (0)