indexing description: "[ leak test example Eiffel version This is an application that checks for possible memoty leaks in the egigs library. ]" status: "See notice at end of class." legal: "See notice at end of class." date: "$Date$" revision: "$Revision$" class APPLICATION inherit ARGUMENTS EGS_SPACE_FINDER create make feature payload_size: INTEGER = 1000; batch_size: INTEGER = 100; default_url: STRING is "/./mySpace" url: STRING feature -- Initialization make is local failed: BOOLEAN mem_info: MEM_INFO mem: MEMORY do if argument_count >= 1 then url := argument (1) else url := default_url end print ("---------- LeakTest running................%N") create mem create mem_info.make ({MEM_INFO}.Eiffel_memory) mem.collect mem.full_collect mem.full_coalesce mem_info.update ({MEM_INFO}.Eiffel_memory) print ("Eiffel mem info: total=" + mem_info.total.out + " used=" + mem_info.used.out + " free=" + mem_info.free.out) mem_info.update ({MEM_INFO}.total_memory) print ("%NTotal mem info: total=" + mem_info.total.out + " used=" + mem_info.used.out + " free=" + mem_info.free.out) print ("%N") from failed := False until failed loop failed := perform_test mem.collect mem.full_collect mem.full_coalesce mem_info.update ({MEM_INFO}.Eiffel_memory) print ("mem info: total=" + mem_info.total.out + " used=" + mem_info.used.out + " free=" + mem_info.free.out) mem_info.update ({MEM_INFO}.total_memory) print ("%Nmem info: total=" + mem_info.total.out + " used=" + mem_info.used.out + " free=" + mem_info.free.out) print ("%N") end --------------------------------------- -- the end --------------------------------------- print ("Press Enter to end hello world%N") io.read_line end perform_test: BOOLEAN is -- Perform tests using provided spase proxy -- return false on failure local space_proxy: EGS_SPACE_PROXY msg, message_template: BENCHMARK_BASE_OBJECT myBatch: ARRAY[EGS_ENTRY] results: ARRAY[EGS_LEASE] results1: ARRAY[EGS_ENTRY] i: INTEGER do --------------------------------------------------- -- retrieving a space proxy --------------------------------------------------- space_proxy := find_space_by_string (url) if space_proxy /= Void then -- print ("Connected to: ") print (url) print (" OK!%N") else -- print ("Failed Connecting to: ") print (url) print ("%N") Result := True end if not Result then --------------------------------------------------- -- doing snapshot for Message --------------------------------------------------- message_template := create_new_object_template space_proxy.snapshot (message_template) -- print ("Did snapshot for PAYLAOD_AS_STRING class%N") create myBatch.make (1, batch_size) from i := 1 until i > batch_size loop msg := create_new_object_for_benchmark myBatch.put (msg, i) i := i + 1 end --------------------------------------------------- -- Write the batch --------------------------------------- results := space_proxy.write_multiple (myBatch, Void, {EGS_LEASE}.forever) -- print ("Wrote a batch to the space:" + myBatch.count.out + "%N") --------------------------------------------------- -- Take the batch --------------------------------------------------- results1 := space_proxy.take_multiple(message_template, Void, batch_size) -- print ("Took a batch from the space:" + results1.count.out + "%N") space_proxy.clear (Void, Void); end end create_new_object_template: BENCHMARK_BASE_OBJECT is do create {PAYLOAD_AS_STRING} Result.make end create_new_object_for_benchmark: BENCHMARK_BASE_OBJECT is local string_payload: STRING res: PAYLOAD_AS_STRING do create string_payload.make_filled ('1', payload_size) create res.make res.set_payload (string_payload) Result := res end indexing copyright: "Copyright (c) 2008, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software 356 Storke Road, Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end -- class APPLICATION