Pastey memory leak
- Posted by useless_
Sep 28, 2012
include std/dll.e
include std/os.e -- sleep
include std/console.e
atom dllptr, kernaldll
integer thistask, FreeDLL
object junk
constant
KERNEL32 = open_dll( "kernel32.dll" ),
FREELIBRARY = define_c_func( KERNEL32, "FreeLibrary", { C_POINTER }, C_INT )
public function free_library( atom dll )
return c_func( FREELIBRARY, { dll } )
end function
--======================================================================================================================
atom starttime = time()
for openloop = 1 to 10000 do
dllptr = open_dll("C:\\Euphoria-4.0.4\\dll_tasks\\kats_tasks2.dll")
if dllptr = 0
then puts(1, "Couldn't open C:\\Euphoria-4.0.4\\dll_tasks\\kats_tasks2.dll!\n")
-- else puts(1,"opened the dll\n")
end if
thistask = define_c_func(dllptr,"task_hello",{E_SEQUENCE},E_SEQUENCE)
if thistask = -1
then puts(1, "thistask could not be found!\n")
-- else puts(1,"thistask was found\n")
end if
junk = c_func(thistask,{"kat"})
--with trace
--trace(1)
free_library(dllptr)
if openloop = 1 then sleep(5) end if -- note memory use after this one load-unload cycle!
end for
puts(1,"seconds to load-call-unload DLL 10k times: "&sprintf("%d",time()-starttime)&"\n\n")
any_key("press something")