S
sheng shan
Hi everyone,
I built a dll which access physical memory in platform builder
4.2,now when I use it in a timer in vb.net with cf,I found it create a
memory leak,my program is like this:
first I declare it in a module:
......
<System.Runtime.InteropServices.DllImport("dualrama.dll",
CallingConvention:=Runtime.InteropServices.CallingConvention.Winapi,
SetLastError:=False)> Public Function ReadByte(ByVal VirtualAddr As
Integer, ByVal offset As Integer) As Byte
End Function
<System.Runtime.InteropServices.DllImport("dualrama.dll",
CallingConvention:=Runtime.InteropServices.CallingConvention.Winapi,
SetLastError:=False)> Public Sub WriteByte(ByVal VirtualAddr As Integer,
ByVal offset As Integer, ByVal myval As Byte)
End Sub
<System.Runtime.InteropServices.DllImport("dualrama.dll",
CallingConvention:=Runtime.InteropServices.CallingConvention.Winapi,
SetLastError:=False)> Public Sub ReadBlock(ByVal VirtualAddr As Integer,
ByVal offset As Integer, ByRef myval As Byte, ByVal mysize As Integer)
End Sub
......
then I call the functions in a timer of one form
......
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Call ReadBlock(VirtualAddr, Current_Baseaddr(4),
Data_Port4(0), 32)
Call ReadBlock(VirtualAddr, Current_Baseaddr(8),
Data_Port8(0), 32)
......
End Sub
...
the functions of the dll work just well,but the memory leak it created
crashed the system after the app running for about 2 hours.
I am trying figure out if it's possible to add some codes in the
timer_tick event to reload and unload the dll which may release the
memory the dll occupied,then the memory leak could be avoided.but how?
or I have to improve my dll code?but I check it again and again and
could find no problem.I would like to post the dll code if anybody is
interested in it.
Help please!
I built a dll which access physical memory in platform builder
4.2,now when I use it in a timer in vb.net with cf,I found it create a
memory leak,my program is like this:
first I declare it in a module:
......
<System.Runtime.InteropServices.DllImport("dualrama.dll",
CallingConvention:=Runtime.InteropServices.CallingConvention.Winapi,
SetLastError:=False)> Public Function ReadByte(ByVal VirtualAddr As
Integer, ByVal offset As Integer) As Byte
End Function
<System.Runtime.InteropServices.DllImport("dualrama.dll",
CallingConvention:=Runtime.InteropServices.CallingConvention.Winapi,
SetLastError:=False)> Public Sub WriteByte(ByVal VirtualAddr As Integer,
ByVal offset As Integer, ByVal myval As Byte)
End Sub
<System.Runtime.InteropServices.DllImport("dualrama.dll",
CallingConvention:=Runtime.InteropServices.CallingConvention.Winapi,
SetLastError:=False)> Public Sub ReadBlock(ByVal VirtualAddr As Integer,
ByVal offset As Integer, ByRef myval As Byte, ByVal mysize As Integer)
End Sub
......
then I call the functions in a timer of one form
......
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Call ReadBlock(VirtualAddr, Current_Baseaddr(4),
Data_Port4(0), 32)
Call ReadBlock(VirtualAddr, Current_Baseaddr(8),
Data_Port8(0), 32)
......
End Sub
...
the functions of the dll work just well,but the memory leak it created
crashed the system after the app running for about 2 hours.
I am trying figure out if it's possible to add some codes in the
timer_tick event to reload and unload the dll which may release the
memory the dll occupied,then the memory leak could be avoided.but how?
or I have to improve my dll code?but I check it again and again and
could find no problem.I would like to post the dll code if anybody is
interested in it.
Help please!