|
-
April 9th, 1999, 09:59 PM
#1
[COM] If memory allocated by malloc() don't freed?
What problems are there if memory allocated by malloc(), C-Library function, is not freed?
A COM program uses old C module using C-Library function. But the module has some problems on memory allocation and deallocation. Sometimes it doesn't deallocate heap memory.
Does COM library automatically free this memory when an instance is destroyed?
I'm confused with thread & COM instance.
I know that a thread doesn't release own heap memory when destroyed.
A COM instance doesn't too?
I'll wait for your kindness.
A programmer who loves Goethe.
-
April 14th, 1999, 10:53 AM
#2
Re: [COM] If memory allocated by malloc() don't freed?
You must free memory manualy by free()
-
May 3rd, 2000, 07:11 PM
#3
Re: [COM] If memory allocated by malloc() don't freed?
It depends how you implement your COM. Most of the time, COM allocates memory space and gives it to the caller, the caller is responsible for deleting it.
In your case, I think COM returns a allocated area of memory to COM client, and inside the client you should release the allocated memory.
Hope it helps. Adios.
Duy D. Tran
[email protected]
-
May 5th, 2000, 03:33 AM
#4
Re: [COM] If memory allocated by malloc() don't freed?
If you dont free memory allocated by malloc() .you will get memory leak when you leav the function body.So if you realy wants no memory leacks in your app better to free all the memory.
-
May 5th, 2000, 05:23 AM
#5
Re: [COM] If memory allocated by malloc() don't freed?
Memory that is passed between COM clients and servers must be allocated using CoTaskMalloc as the COM remoting architecture will expect it.
COM makes no attempt to clean up objects or any of the resources allocated by the object, it is up to the object to clean up these resources when it's ref count goes to zero. If the object is in an out-of-process server then its resources will be reclaimed by the operating system when the server process closes.
Small memory leaks are acceptable if they only happen occasionaly and the server is not expected run for extended periods (remember you have 2GB virtual memory per process), but the cumulative effect of repeated memory leaks on performance can be devistating due to the extra pageing to and from swap file required.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|