Skip to content

Instantly share code, notes, and snippets.

@kattrali
Created August 25, 2010 03:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kattrali/548785 to your computer and use it in GitHub Desktop.
Save kattrali/548785 to your computer and use it in GitHub Desktop.
Testing the Disposal of SWT resources
require 'java'
require 'swt.jar'
class SwtTest
include_package 'org.eclipse.swt.widgets'
import 'org.eclipse.swt.SWT'
def run
puts "Press Enter to Start"
#pause, in case you wan to attach a profiler
gets
shell = Shell.new(Display.new)
shell.layout = org.eclipse.swt.layout.FormLayout.new
#shell.visible = true
i = 0
while true
menu_bar = Menu.new(shell, SWT::DROP_DOWN)
5.times do
menu = Menu.new(menu_bar)
(1..10).each do |j|
item_1 = MenuItem.new(menu, SWT::CASCADE)
item_1.text = "Item #{j}"
end
#menu.visible = true
end
menu_bar.dispose
i = i+1
if (i % 100) == 0
puts i
puts "#{menu_bar} <-- sample menu bar"
end
end
end
end
SwtTest.new.run
require 'java'
require 'swt.jar'
class SwtTest
include_package 'org.eclipse.swt.widgets'
import 'org.eclipse.swt.SWT'
def run
puts "Press Enter to Start"
#pause, in case you wan to attach a profiler
gets
display = Display.new
i = 0
while true
shell = Shell.new(display)
shell.layout = org.eclipse.swt.layout.FormLayout.new
#shell.visible = true
menu_bar = Menu.new(shell, SWT::DROP_DOWN)
5.times do
menu = Menu.new(menu_bar)
(1..10).each do |j|
item_1 = MenuItem.new(menu, SWT::CASCADE)
item_1.text = "Item #{j}"
end
#menu.visible = true
end
shell.dispose
i = i+1
if (i % 50) == 0
puts i
puts "#{shell} <-- sample shell"
end
end
end
end
SwtTest.new.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment