humble_learner
June 13th, 2008, 07:19 AM
Hi,
[Application]
The application consists of two physical parts - a .NET based GUI and a C++ based DLL.
[Functionality]
A. A user can provide details of a class (teachers name and students names) in the GUI and clicks on a button. The data is passed to the C++ DLL where it is written into a file.
B. A user can read the contents of a file and display on the GUI. In this case the C++ DLL reads the file contents and sends the data across to the UI.
In case A, memory is allocated by the Managed C# code and sent across to the C++ DLL (because the front end knows about the number of students on reading GUI entries)
In case B, the managed code sends across a 'ref' parameter to the C++ DLL. Memory is allocated in the C++ DLL and returned to the C# GUI for display (because the back end knows about the number of students on reading file)
I would like help to understand how best to design the interfaces between the GUI and the DLL so as to prevent memory leaks. Who has the responsibility of deleting allocated memory ?
Please let me know your views.
Thanks,
Humble Learner
[Application]
The application consists of two physical parts - a .NET based GUI and a C++ based DLL.
[Functionality]
A. A user can provide details of a class (teachers name and students names) in the GUI and clicks on a button. The data is passed to the C++ DLL where it is written into a file.
B. A user can read the contents of a file and display on the GUI. In this case the C++ DLL reads the file contents and sends the data across to the UI.
In case A, memory is allocated by the Managed C# code and sent across to the C++ DLL (because the front end knows about the number of students on reading GUI entries)
In case B, the managed code sends across a 'ref' parameter to the C++ DLL. Memory is allocated in the C++ DLL and returned to the C# GUI for display (because the back end knows about the number of students on reading file)
I would like help to understand how best to design the interfaces between the GUI and the DLL so as to prevent memory leaks. Who has the responsibility of deleting allocated memory ?
Please let me know your views.
Thanks,
Humble Learner