- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've got a large fortran com server program that compiles to a dll andhas various methods that are called from VB.net. The com server was created using the intel wizard so it comes with the various wrappers etc. It all seems to be working fine apart from the fact that the memory doesn't seem to clear between calls from the vb program.Some variables in the fortranretain their values from the last call. Also the memory allocation keeps increasing with repeated calls.
The fortran DLL is called as a local object in VB.net and it loses scope between calls so it should die off? And setting it to = nothing doesn't help either. Is there some fortran termination code that I need to add? and if so where should I stick it?Help!
thanks,
Jonathan.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi, Jonathan Mills
Could yougive us any examples on how youuse those dll functions?
E.g.: if you use server_CONSTRUCTOR to allocate resources, you should use server_DESTRUCTOR to release those resources afterwards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi, Jonathan Mills
Could yougive us any examples on how youuse those dll functions?
E.g.: if you use server_CONSTRUCTOR to allocate resources, you should use server_DESTRUCTOR to release those resources afterwards.
Hi Yolanda -
Below is the destructor code generated by the com server wizard. Some destructor code is in the USiliconCow3Ty.f90 file and this is called from the SiliconCow3_Release function that is in the SiliconCow3TY.f90 file. I have pasted the Release function first followed by the destructor subroutine.
It looks like the destructor routine is essentiallyempty to me but I have no idea what I should be adding if anything? Any help would be much appreciated - if you want me to upload anything then do let me know.
Thanks,
Jonathan.
!Release Function is below:
!****************************************
function SiliconCow3_Release (pData) result
!dec$ attributes stdcall :: SiliconCow3_Release
use ifwinty
use SiliconCow3_global
implicit none
type (ISiliconCow3_Ptr) pData
!dec$ attributes reference :: pData
integer r
type (SiliconCow3_Data), pointer :: pSiliconCow3Data
integer status
pData % pInternalData % refCount = &
pData % pInternalData % refCount - 1
r = pData % pInternalData % refCount
if (pData % pInternalData % refCount == 0) then
! Time to delete ourself....
pSiliconCow3Data => pData % pInternalData % pStart
! Call the "destructor"
call SiliconCow3_DESTRUCTOR(pSiliconCow3Data % InternalData % pInstanceData)
! Per interface
deallocate (pSiliconCow3Data % ISiliconCow3_InternalData % pVtbl)
deallocate (pSiliconCow3Data % InternalData % pInstanceData)
deallocate (pSiliconCow3Data)
status = ServerUnlock()
end if
end function
!Destructor routine is below:
!*******************************************************
! USiliconCow3TY.f90 - This module contains user-defined class
! definitions and methods
!
module SiliconCow3_USE
type SiliconCow3_InstanceData
sequence
!
! TODO: Add fields and remove "dummy"
integer dummy
!
end type
contains
!
! Constructor
!
function SiliconCow3_CONSTRUCTOR( ObjectData ) result (hresult)
use ifwinty
implicit none
type(SiliconCow3_InstanceData) ObjectData
!dec$ attributes reference :: ObjectData
integer(LONG) hresult
hresult = S_OK
!
! TODO: Add field initialization code
!
end function
!
! Destructor
!
subroutine SiliconCow3_DESTRUCTOR( ObjectData )
implicit none
type(SiliconCow3_InstanceData) ObjectData
!dec$ attributes reference :: ObjectData
!
! TODO: Add field cleanup code
!
end subroutine
end module
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
See from the Programer's Guide:
The classname_CONSTRUCTOR procedure is called immediately after an instance of the class derived-type is created because of the creation of a new object. This function is where you initialize the fields of the class derived-type, if necessary. The new derived-type is passed as an argument to the function. For the AddingMachine class, we initialize the current value to 0 by adding the following statement:
ObjectData%CurrentValue = 0
The classname_DESTRUCTOR procedure is called immediately before an instance of the class derived-type is destroyed because an object is being destroyed. This function is where you release any resources used by the fields of the class derived-type, if necessary. The derived-type is passed as an argument to the function. For the AddingMachine class, there is nothing that needs to be added.
I think you may release resources within this desctructor instead of calling it inother functions, since this desctructor will be invoked immediately before the object is destroyedby thegenerated COM server.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page