Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Memory leaks after moving from MultiByte to Unicode Collapse All
Subject Author Date
Dennis Ioakim Mar 5, 2010 - 3:10 AM

Good day,


We recently moved one of our projects from a MultiByte build to a Unicode build. Th only things changed in the project are the chars becoming wchars and strings becoming wstrings.


We also compiled the DLL version of Prof-UIS by using :

#define __EXT_MFC_ENABLE_TEMPLATED_CHARS

and

#define __EXT_MFC_COMPILED_WITH_NATIVE_WCHAR_T





Our project compiles and runs successfully but upon termination, many memory leaks appear. Most of them are associated with three files from the Prof-UiS library:

ExtCmdManager.cpp

ExtCmdIcon.cpp

ExtPaintManager2.cpp


So I would like to know if you have found similar issues and a way to resolve them,

and I would also like to know if there is any "special" way to handle our Unicode project that we  probably overlooked.


Thanks in advance.

Technical Support Mar 11, 2010 - 7:37 AM

If your DLLs are MFC based, then you should convert all of them to Unicode and there are no other solutions available in this case. If your DLLs are non-MFC, then you can leave them as is and just pass non-Unicode strings into DLL API invocations and correctly process returned non-Unicode strings. Please provide us with more details about your DLLs.

Technical Support Mar 5, 2010 - 10:23 AM

We suspect your application was simply terminated unexpectedly. Too many memory leaks typically mean that nothing was deallocated. This can happen if the ExitProcess() or ExitThread() APIs were invoked before complete shutdown. This can happen when an exception occurs while handling other exception. You can configure your Visual Studio to break into debugger on any exceptions even if they are handled. This will show you the point when your application terminates itself instead of performing successful shutdown actions.

Dennis Ioakim Mar 11, 2010 - 2:55 AM

Good day,


After some testing I found the cause of the leaks. In our now-Unicode project there are some calls to load non-Unicode dll’s.

When unloading those dll’s the mentioned memory leaks occur. We tested with a very simple (empty) dll and the behavior was the same.



So to reproduce this do the following:


Load a Unicode dll from a Unicode Profuis test project  ---> Everything ok when dll is unloaded!

Load a Multibyte dll from a Unicode Profuis test project  ---> Tons of memory leaks when dll is unloaded!


Once again many of the memory leaks are in ExtCmdManager.cpp and other ProfUIS files as mentioned before.



One solution is to transform those dll’s in Unicode, but some of them aren’t created by us.

What other solution could you suggest?



Thanks in advance.


 

Dennis Ioakim Mar 15, 2010 - 8:08 AM

Hello again,


i have found the cause of the many memory leaks. When using MFC Unicode version and calling a DLL containing MFC calls non-Unicode version or the opposite  ( non-Unicode MFC  project calling a Unicode MFC DLL) memory leaks appear when unloading that particular DLL file.


These leaks according to Miscrosoft are false as the only true leaks are reported after program termination.



This topic is explained in more detail here: http://support.microsoft.com/kb/q167929/#@lt;/p>

 


So there are no real issues with the Prof-UIS library.