|
|
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » Warning Heap memory leak when closing program
Warning Heap memory leak when closing program [message #32523] |
Mon, 23 May 2011 19:08 |
silverx
Messages: 62 Registered: March 2011
|
Member |
|
|
I am getting an error when I close my program that says warning memory leak detected.
This is in windows vista, when I close the program.
I only get it when I call a dll, that was written by Microsoft, which is winmm.dll.
From what I am reading on the web, they say it was designed that way, and it is not a bug.
I have included the program which is very simple along with the needed dll, and a sound file to play.
How can I capture this warning when closing the program and not have it displayed for a user of the program?
NOW HAPPY
-
Attachment: t3.zip
(Size: 320.03KB, Downloaded 372 times)
[Updated on: Mon, 23 May 2011 22:55] Report message to a moderator
|
|
|
Re: Warning Heap memory leak when closing program [message #32524 is a reply to message #32523] |
Mon, 23 May 2011 19:52 |
|
silverx wrote on Mon, 23 May 2011 19:08 | How can I capture this warning when closing the program and not have it displayed for a user of the program?
|
Put MemoryIgnoreLeaksBegin()/MemoryIgnoreLeaksEnd() end around the call to the function that causes the leak. Alternatively, create an object of type MemoryIgnoreLeaksBlock, it will call these functions in constructor/destructor, thus affecting everything from its creation till the end of scope.
Best regards,
Honza
PS: Best solution would be of course to use non-leaking library
|
|
|
|
Re: Warning Heap memory leak when closing program [message #32533 is a reply to message #32525] |
Tue, 24 May 2011 07:32 |
|
Hi David,
silverx wrote on Mon, 23 May 2011 20:56 | Thanks. I used the memoryIgnoreLeaksBegin()/MemoryIgnoreLeaksEnd() end around the call to the function, and that worked great.
|
You're welcome
silverx wrote on Mon, 23 May 2011 20:56 | While I would love to use one without the memory leak, it is actually a standard dll that Microsoft created and can be used to play a .wav file. It was pointed out to them about the memory leak, but their response was it was designed that way.
And I don't currently have the knowledge on how to de-compile their dll and then recode it not to have the memory leak, no how to code the functions that their dll provides.
| Well, what can you expect from M$... No need to decompile and fix their mess. You can try plugin/wav from bazaar, it has a metod PlayWav, which should work just fine for your purposes. It uses portaudio as a backend, so it is portable and platform independent.
silverx wrote on Mon, 23 May 2011 20:56 | And for others this has a working example of using a dll on windows. I couldn't get the example provided by U++ for doing dll function calls to work. But this simple code works great.
|
Anyway, wouldn't it be simpler to just #include <mmsystem.h> in your code and add winmm to the libraries in package organizer? But I'm no windows programmer, so if I'm talking nonsense here, just ignore it
Honza
PS: Forgot to mention that you can have a look at SoundExample from bazaar to see more options how to handle sound in U++. It also contains an example using the mentioned PlayWav function...
[Updated on: Tue, 24 May 2011 07:35] Report message to a moderator
|
|
|
|
|
Re: Warning Heap memory leak when closing program [message #32541 is a reply to message #32533] |
Tue, 24 May 2011 10:15 |
silverx
Messages: 62 Registered: March 2011
|
Member |
|
|
I did look at the soundexample in bazaar, but when I try and execute it, I get all of the below messages which have a bunch of errors listed.
I also tried a few other examples from the bazaar area, but usually got a bunch of errors so I finally stopped going through the bazaar stuff. It would be nice if the bazaar items actually work like the examples.
----- Sound ( ALSA MSC9 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (1 / 12)
BLITZ: Sound.cpp SoundStream.cpp SoundSystem.cpp
----- CtrlLib ( MSC9 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (2 / 12)
BLITZ: LabelBase.cpp Button.cpp Switch.cpp EditField.cpp Text.cpp LineEdit.cpp DocEdit.cpp ScrollBar.cpp HeaderCtrl.cpp ArrayCtrl
.cpp MultiButton.cpp PopupTable.cpp DropList.cpp DropChoice.cpp Static.cpp Splitter.cpp FrameSplitter.cpp SliderCtrl.cpp Colu
mnList.cpp Progress.cpp AKeys.cpp RichTextView.cpp Prompt.cpp Help.cpp DateTimeCtrl.cpp Bar.cpp MenuItem.cpp MenuBar.cpp Tool
Button.cpp ToolBar.cpp ToolTip.cpp StatusBar.cpp TabCtrl.cpp TreeCtrl.cpp DropTree.cpp DlgColor.cpp ColorPopup.cpp ColorPushe
r.cpp FileList.cpp FileSel.cpp FileSelUtil.cpp PrinterJob.cpp Windows.cpp Win32.cpp TrayIconWin32.cpp TrayIconX11.cpp CtrlUti
l.cpp Update.cpp LNGCtrl.cpp Ch.cpp ChGtk.cpp
$blitz.cpp
c:\myapps\sound\Sound.h(117) : error C2027: use of undefined type 'Upp::SoundSystem'
c:\myapps\sound\Sound.h(51) : see declaration of 'Upp::SoundSystem'
C:\MyApps\Sound\Sound.cpp(28) : error C2027: use of undefined type 'Upp::SoundSystem'
c:\myapps\sound\Sound.h(51) : see declaration of 'Upp::SoundSystem'
C:\MyApps\Sound\Sound.cpp(28) : error C3861: 'Exists': identifier not found
C:\MyApps\Sound\Sound.cpp(37) : error C2027: use of undefined type 'Upp::SoundSystem'
c:\myapps\sound\Sound.h(51) : see declaration of 'Upp::SoundSystem'
C:\MyApps\Sound\Sound.cpp(37) : error C3861: 'Exists': identifier not found
C:\MyApps\Sound\SoundSystem.cpp(42) : error C2027: use of undefined type 'Upp::SoundSystem'
c:\myapps\sound\Sound.h(51) : see declaration of 'Upp::SoundSystem'
C:\MyApps\Sound\SoundSystem.cpp(44) : error C2079: 'x' uses undefined class 'Upp::SoundSystem'
C:\MyApps\Sound\SoundSystem.cpp(46) : error C2027: use of undefined type 'Upp::SoundSystem'
c:\myapps\sound\Sound.h(51) : see declaration of 'Upp::SoundSystem'
C:\MyApps\Sound\SoundSystem.cpp(46) : error C2059: syntax error : ')'
C:\MyApps\Sound\SoundSystem.cpp(46) : error C2143: syntax error : missing ';' before '{'
C:\MyApps\Sound\SoundSystem.cpp(46) : error C2447: '{' : missing function header (old-style formal list?)
C:\MyApps\Sound\SoundSystem.cpp(53) : error C2027: use of undefined type 'Upp::SoundSystem'
c:\myapps\sound\Sound.h(51) : see declaration of 'Upp::SoundSystem'
C:\MyApps\Sound\SoundSystem.cpp(53) : error C2059: syntax error : ')'
C:\MyApps\Sound\SoundSystem.cpp(53) : error C2143: syntax error : missing ';' before '{'
C:\MyApps\Sound\SoundSystem.cpp(53) : error C2447: '{' : missing function header (old-style formal list?)
C:\MyApps\Sound\SoundSystem.cpp(59) : error C2027: use of undefined type 'Upp::SoundSystem'
c:\myapps\sound\Sound.h(51) : see declaration of 'Upp::SoundSystem'
C:\MyApps\Sound\SoundSystem.cpp(59) : error C2270: 'GetCount' : modifiers not allowed on nonmember functions
C:\MyApps\Sound\SoundSystem.cpp(60) : error C2065: 'err' : undeclared identifier
C:\MyApps\Sound\SoundSystem.cpp(61) : error C2673: 'Upp::GetCount' : global functions do not have 'this' pointers
C:\MyApps\Sound\SoundSystem.cpp(61) : error C2228: left of '.IsError' must have class/struct/union
C:\MyApps\Sound\SoundSystem.cpp(61) : error C2673: 'Upp::GetCount' : global functions do not have 'this' pointers
C:\MyApps\Sound\SoundSystem.cpp(61) : error C2228: left of '.GetError' must have class/struct/union
C:\MyApps\Sound\SoundSystem.cpp(62) : error C2065: 'err' : undeclared identifier
C:\MyApps\Sound\SoundSystem.cpp(65) : error C2027: use of undefined type 'Upp::SoundSystem'
c:\myapps\sound\Sound.h(51) : see declaration of 'Upp::SoundSystem'
C:\MyApps\Sound\SoundSystem.cpp(65) : error C2270: 'GetAPICount' : modifiers not allowed on nonmember functions
C:\MyApps\Sound\SoundSystem.cpp(66) : error C2065: 'err' : undeclared identifier
C:\MyApps\Sound\SoundSystem.cpp(67) : error C2673: 'Upp::GetAPICount' : global functions do not have 'this' pointers
C:\MyApps\Sound\SoundSystem.cpp(67) : error C2228: left of '.IsError' must have class/struct/union
C:\MyApps\Sound\SoundSystem.cpp(67) : error C2673: 'Upp::GetAPICount' : global functions do not have 'this' pointers
C:\MyApps\Sound\SoundSystem.cpp(67) : error C2228: left of '.GetError' must have class/struct/union
C:\MyApps\Sound\SoundSystem.cpp(68) : error C2065: 'err' : undeclared identifier
C:\MyApps\Sound\SoundSystem.cpp(71) : error C2027: use of undefined type 'Upp::SoundSystem'
c:\myapps\sound\Sound.h(51) : see declaration of 'Upp::SoundSystem'
C:\MyApps\Sound\SoundSystem.cpp(71) : error C2270: 'GetDevices' : modifiers not allowed on nonmember functions
C:\MyApps\Sound\SoundSystem.cpp(76) : error C2065: '__$ReturnUdt' : undeclared identifier
C:\MyApps\Sound\SoundSystem.cpp(76) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Sound: 3 file(s) built in (0:00.70), 234 msecs / file, duration = 1684 msecs, parallelization 99%
ChWin32.cpp
CtrlLib.icpp
$blitz.cpp
CtrlLib: 53 file(s) built in (0:06.03), 113 msecs / file, duration = 6958 msecs, parallelization 95%
There were errors. (0:07.33)
|
|
|
|
Re: Warning Heap memory leak when closing program [message #32557 is a reply to message #32541] |
Tue, 24 May 2011 19:50 |
|
silverx wrote on Tue, 24 May 2011 10:15 | I did look at the soundexample in bazaar, but when I try and execute it, I get all of the below messages which have a bunch of errors listed.
I also tried a few other examples from the bazaar area, but usually got a bunch of errors so I finally stopped going through the bazaar stuff. It would be nice if the bazaar items actually work like the examples.
|
I am not a windows user, so supporting MSVC compiler and testing is bit harder for me. Also, bazaar provides code "as is", most of it works although as you noticed sometimes exceptions exist. Most of the problems is probably caused by insufficient testing, as in this case...
Anyway, I fixed the sound stuff to work with MSVC. I encountered some problems with WASAPI, so if you get some runtime errors, please try compiling it with "GUI .WMME" flags to use only WMME. If you are still interested of course
Honza
|
|
|
|
Re: Warning Heap memory leak when closing program [message #32571 is a reply to message #32566] |
Wed, 25 May 2011 11:17 |
|
silverx wrote on Wed, 25 May 2011 09:12 | Yes, still interested in it.
How would I get a new copy of the fixed code, so I can try it again?
David
|
The easiest way is to just install newer version of U++, version 3455 (or newer). Or, if you are using svn, just update your working copy.
Honza
|
|
|
|
Goto Forum:
Current Time: Fri Nov 01 00:57:05 CET 2024
Total time taken to generate the page: 0.01472 seconds
|
|
|