|
I have created Resource only DLLs already but my system is not supporting all languages.
This will happen with the client also. So how can I support languages without installing language pack either through WIN XP CD or through microsoft site.
Where can I get free language pack which I can attach with my software.
Plz reply soon.
Thanks
|
|
|
|
|
Hi ,
I have a problem of memory leak when we call a function from win 32 DLL in our MFC program.
DLL is C type and return value of my DLL is Char* and it is locally defined in function of DLL. and size is 1024 byte.
when functon call four times then MFC application hold 4 KB Extra memory.
|
|
|
|
|
Is the DLL allocating memory that the char* points to, on the heap? Probably then the calling application must free this memory up? Do you have any docs for that DLL? Or if you have the source code, you may verify this.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
i m using New and Delete in calling application(MFC).
but "delete []cData;" line have error runtime.
if we use cData='\0' and after this "delete []cData;"
then memory leak still continue.
how can free memory in MFC application.
|
|
|
|
|
If the memory is allocated with new in the DLL, then clean it up with delete after you've used the data. Where is the difficulty? I don't see anything more to 'discuss' about here.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Actually i am using static linking a dll.
so when we used delete then runtime error occor about heap
|
|
|
|
|
When returning char* as return value, you must allocate memory in heap(using malloc or new), from your DLL and deallocate this memory(free or delete) after usage from the calling applciation.
prvn
|
|
|
|
|
i m using New and Delete in calling application(MFC).
but "delete []cData;" line have error runtime.
if we use cData='\0' and after this "delete []cData;"
then memory leak still continue.
|
|
|
|
|
shivanandgupta wrote: if we use cData='\0' and after this "delete []cData;"
then memory leak still continue.
That should not be a surprise...
Either you are just making a silly mistake (which we all do), or it's a bit more complex and you are allocating and freeing from different heaps. This could happen if you statically link to the C++ runtime.
One simple choice would be to use IMalloc to allocate / free chunks of memory. Look at CoGetMalloc etc for documentation.
I still think it's likely to be something dumb... Are you sure the memory is not already freed elsewhere?
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Thanks for Reply
i am calling DLL statically
|
|
|
|
|
i don't have any idea to use Imalloc and cogetmalloc function to free memory.
i m using statically DLL not a COM
|
|
|
|
|
shivanandgupta wrote: if we use cData='\0' and after this "delete []cData;"
then memory leak still continue.
Well, if you set cData to '\0' you are manipulating the pointer, not the data it contains.
cData is set to null, and that is what you try to delete (and it always succeeds.)
Doesn't the DLL supply an API for freeing this string? IMHO dll's should always be designed that way.
|
|
|
|
|
if we use delete without using '\0' then problem occur about heap at run time.
|
|
|
|
|
Well, setting it to '\0' is the same as setting it to NULL. In either case, it makes the delete call a no-op, and that's why you don't get a crash, but you DO get a memory leak.
|
|
|
|
|
If the DLL allocates the memory using new , it should also be the one to delete[] it. So, let the DLL export a new function to free memory.
In your MFC program, you'd call the original method to allocate the char*, and afterwards you'd pass this pointer to the freeing function of the DLL, which would just delete[] it.
|
|
|
|
|
If the application is being build with the runtime libary (CRT) as a DLL (Recommended by Microsoft), then it should be possible to delete memory in the application that have been allocated by the DLL.
|
|
|
|
|
Correct. Based on the original question and replies, it was my impression that different heaps/CRTs are being used (see static linkage post), that's why I suggested this way. Of course, using only one CRT will solve the problem, too.
|
|
|
|
|
I m unable to use CRT
can u give some kind of code
|
|
|
|
|
Just follow what Dominik Reichl said in the first comment about ensuring that memory allocated in the DLL is released by the DLL again. Return the char-pointer to the DLL and let the DLL release it again.
|
|
|
|
|
return data char* is locally defined in DLL.
so how can release memory of that variable after returning
char* variable
|
|
|
|
|
When returning the char* then you take a copy of the char*, but they both point to the same memory in the heap of the DLL.
Just pass the copy of the char* from the application to the DLL again, and let the DLL release the memory in its heap.
You might consider returning a CString instead of a char*, and ensure that when the CString moves from DLL boundary to the Application boundary that a copy is made of the CString.
|
|
|
|
|
I have try but it is not working.
return char* is defined in dll's function as a local variable.
it will work well when we defined static variable. but i don't want
to create static variable in my DLL.
|
|
|
|
|
Thank you for confirming this. I'm in a situation myself where I'm considering to convert static-libraries into DLL's to improve linker times. The entire application is already using runtime library as DLL, so the conversion should be a matter of exporting all needed classes in the static libraries.
|
|
|
|
|
Hi...
i am creating a application in win32. i need to access the sql or MSAccess databse. but i don't know how to connect win32 application with sql or MSAccess database. please can any one help me?
thanking you
G.Paulraj
|
|
|
|
|
Are you using MFC? If so, then the MFC database connectivity classes[^] will be useful.
If you're not using MFC, then the ATL database classes[^] may be useful.
Other alternative technologies are ODBC[^], ADO[^] or DAO[^]. They'll all be painful (to some degree) to use with raw C++.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|