Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » Warning Heap memory leak when closing program
icon7.gif  Warning Heap memory leak when closing program [message #32523] Mon, 23 May 2011 19:08 Go to next message
silverx is currently offline  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 192 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 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1758
Registered: August 2008
Location: Czech Republic
Senior Contributor

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 Wink
icon7.gif  Re: Warning Heap memory leak when closing program [message #32525 is a reply to message #32524] Mon, 23 May 2011 20:56 Go to previous messageGo to next message
silverx is currently offline  silverx
Messages: 62
Registered: March 2011
Member
Thanks. I used the memoryIgnoreLeaksBegin()/MemoryIgnoreLeaksEnd() end around the call to the function, and that worked great.

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.

Again thank you. It works great now.

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.

David
Re: Warning Heap memory leak when closing program [message #32533 is a reply to message #32525] Tue, 24 May 2011 07:32 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1758
Registered: August 2008
Location: Czech Republic
Senior Contributor

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 Wink

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 Wink

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 #32534 is a reply to message #32525] Tue, 24 May 2011 08:39 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12098
Registered: November 2005
Ultimate Member
silverx wrote on Mon, 23 May 2011 14:56

Thanks. I used the memoryIgnoreLeaksBegin()/MemoryIgnoreLeaksEnd() end around the call to the function, and that worked great.

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.

Again thank you. It works great now.

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.

David


If I may, it is still a little bit weird. U++ only cares about leaks caused by calling new/delete. It is quite unlikely that winmm is using C++ new/delete inside its code.

Mirek
Re: Warning Heap memory leak when closing program [message #32536 is a reply to message #32534] Tue, 24 May 2011 08:45 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12098
Registered: November 2005
Ultimate Member
OK, found the bug, you have wrong singnature of imported function, obviously winmm.dll knows nothing about U++ String type...

void t3::PlayIt()
{
	
	typedef int (*importFunction)(const char *, long);
	


With this change, no leaks, no issues, no need to ignore leaks.

Mirek

[Updated on: Tue, 24 May 2011 08:46]

Report message to a moderator

icon13.gif  Re: Warning Heap memory leak when closing program [message #32541 is a reply to message #32533] Tue, 24 May 2011 10:15 Go to previous messageGo to next message
silverx is currently offline  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)
icon7.gif  Re: Warning Heap memory leak when closing program [message #32542 is a reply to message #32536] Tue, 24 May 2011 10:18 Go to previous messageGo to next message
silverx is currently offline  silverx
Messages: 62
Registered: March 2011
Member
I gave this a try, and it worked great.

Thank you.
Re: Warning Heap memory leak when closing program [message #32557 is a reply to message #32541] Tue, 24 May 2011 19:50 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1758
Registered: August 2008
Location: Czech Republic
Senior Contributor

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 Smile

Honza
Re: Warning Heap memory leak when closing program [message #32566 is a reply to message #32557] Wed, 25 May 2011 09:12 Go to previous messageGo to next message
silverx is currently offline  silverx
Messages: 62
Registered: March 2011
Member
Yes, still interested in it.

How would I get a new copy of the fixed code, so I can try it again?

David
Re: Warning Heap memory leak when closing program [message #32571 is a reply to message #32566] Wed, 25 May 2011 11:17 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1758
Registered: August 2008
Location: Czech Republic
Senior Contributor

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
icon14.gif  Re: Warning Heap memory leak when closing program [message #32576 is a reply to message #32571] Wed, 25 May 2011 15:57 Go to previous message
silverx is currently offline  silverx
Messages: 62
Registered: March 2011
Member
I did get the updated, and then tried it. It now works great.

Thank you for the fixes to the programs.

David
Previous Topic: MINGW resource compile problem , M$ Windows
Next Topic: C2143 Error on even simple window with just one label? Help? What happened?
Goto Forum:
  


Current Time: Fri Nov 15 03:54:47 CET 2019

Total time taken to generate the page: 0.02259 seconds