|
memory leak with install_sound() - allegro 4.2.3 |
xadow123
Member #14,602
October 2012
|
Hello everybody! New forum member here and my first post. Now, let me get to business. If you compile and run the code below, all goes well. However, when the 1#include <allegro.h>
2#include <crtdbg.h>
3
4int main()
5{
6 //memory leak detector
7 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
8
9 allegro_init();
10
11 set_color_depth(32);
12 set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
13
14 install_keyboard();
15 install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL);
16
17 readkey();
18
19 return 0;
20}
21END_OF_MAIN()
|
weapon_S
Member #7,859
October 2006
|
xadow123 said: Is this a bug in the library? Possibly... |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Allegro 4.2.3 is the latest binary version of Allegro 4. Both are outdated by Allegro 5, so unless you have a reason for using 4, move on to 5. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
xadow123
Member #14,602
October 2012
|
thanks for the replies. i'll try my luck with allegro 4.4.1. i've already started learning allegro 4.2 since that's what my learning material uses. moving on with allegro 5 would require some time learning things again. seeing some source code for allegro 5, the syntax are different and probably the way of doing things. i'll get back here to tell you guys the results. [EDIT]: i've tried with allegro 4.4.2 but unfortunately there are still memory leaks but from 6 its now down to only 2. memory leak in 4.2.3: {"name":"memory_leak_in_allegro_4_2_3.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/d\/9ddaca22cbddfc4d9979ae0178595a1f.png","w":1141,"h":306,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/d\/9ddaca22cbddfc4d9979ae0178595a1f"} memory leak in 4.4.2: {"name":"memory_leak_in_allegro_4_4_2.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/4\/74c7a1e04e479cfdd7cd8873ba6b09d0.png","w":565,"h":190,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/4\/74c7a1e04e479cfdd7cd8873ba6b09d0"} source code: 1#include <allegro.h>
2#include <crtdbg.h>
3
4int main()
5{
6 //memory leak detector
7 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
8
9 allegro_init();
10
11 set_color_depth(32);
12 set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
13
14 install_keyboard();
15 install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
16
17 readkey();
18
19 remove_sound();
20 allegro_exit();
21
22 return 0;
23}
24END_OF_MAIN()
can you guys check if the memory leaks are also present in allegro 5 when initializing the sound module. |
weapon_S
Member #7,859
October 2006
|
[Copied over from other thread] |
xadow123
Member #14,602
October 2012
|
@weapons_S i'm no expert either. in fact, i only understood the string "Detected memory leaks!" and i really don't know that much about "_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); also i think that the memory leak detector code above is working fine. i tested it with a simple undeleted "int* x = new int;" and it detected the memory leak. i also included "allegro-4.4.2-monolith-md-debug.lib" in config prop->linker->input->additional dependencies. i don't know what's the difference b/w an MT and MD debug. i simply followed the instructions given in this site: http://wiki.allegro.cc/index.php?title=Windows,_Visual_Studio_2010_and_Allegro_5. i think its also applicable with allegro 4.4.2. weapon_S said: I'm hoping that when you link with the appropriate allegro-debug the weird numbers will turn into something understandable are you referring to this one: allegro-4.4.2-monolith-md-debug.lib? |
weapon_S
Member #7,859
October 2006
|
Yep, that's what I mean. Try the /MD linker flag, #define _DEBUG at the start of your file, and link with that specific file. (And set project to "debug"???) ) |
xadow123
Member #14,602
October 2012
|
sorry, just now. been busy lately. okay here's what i did basing from your instructions. i'm not sure if i did it right. 1. went to project property pages->c/c++->code generation->runtime library. changed the value from Multi-threaded Debug DLL (/MDd) to Multi-threaded DLL (/MD) {"name":"step1.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/0\/e098f4448048162b203624b532b359cd.png","w":849,"h":595,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/0\/e098f4448048162b203624b532b359cd"} 2. changed the code to this one: 1#include <allegro.h>
2#include <crtdbg.h>
3
4int main()
5{
6 //memory leak detector
7 #if defined(DEBUG) | defined(_DEBUG)
8 _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF );
9 #endif
10
11 allegro_init();
12
13 set_color_depth(32);
14 set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
15
16 install_keyboard();
17 install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
18
19 readkey();
20
21 remove_sound();
22 allegro_exit();
23
24 return 0;
25}
26END_OF_MAIN()
3. there's no allegro-4.2.3-monolith-md-debug.lib in allegro 4.2.3 so i went to project property pages->linker->input->addt'l dependencies then added alld.lib. configuration is also set to debug. {"name":"step3.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/3\/e35eb7af28518a836f60b36a9e97c662.png","w":851,"h":599,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/3\/e35eb7af28518a836f60b36a9e97c662"} 4. no more memory leaks: {"name":"step_4.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/5\/15dda432a907d72b728c860ae0d1ec6f.jpg","w":1023,"h":541,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/5\/15dda432a907d72b728c860ae0d1ec6f"} i quite don't understand what happened. is there a memory leak or not? can somebody explain please. |
weapon_S
Member #7,859
October 2006
|
What you're doing now seems opposite to what I meant. Now you're not linking to the debug build. I've downloaded 4.4.2. Using MSVC 10 (2010 Express). Linked with debug-md. Using the provided dependency libraries or from the Allegro 5 package made no difference. Dumping objects -> {725} normal block at 0x016E8188, 24 bytes long. Data: < Y > E0 59 20 00 FF FF FF FF 00 00 00 00 00 00 00 00 {724} normal block at 0x016EEAB0, 2048 bytes long. Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Object dump complete. The program '[3740] all44_debug1.exe: Native' has exited with code 0 (0x0).
Dumping objects seems MSVC always does in debug. In your previous posts you have perhaps cropped off the relevant information (before "Memory leaks detected"). References
|
xadow123
Member #14,602
October 2012
|
i barely have any knowledge on using msvc's debug tools and _CrtSetDbgFlag so i'm really just making wild guesses. what i have here is allegro 4.2 and there's no monolith-md-debug.lib for 4.2. i have the 4.4.2 on another computer. sorry for double posting. i'll just be posting here everything about the install_sound() "memory leak". i've downloaded 4.4.2 and follow the instructions given here: http://wiki.allegro.cc/index.php?title=Windows,_Visual_Studio_2010_and_Allegro_5 run the above code again and here's the full debug output: 'allegro_coding.exe': Loaded 'C:\Users\xadow123\Documents\Visual Studio 2010\Projects\allegro_coding\Debug\allegro_coding.exe', Symbols loaded. |
|