Homebrew Check memory leaks and debuging in 3ds development

antoniorand

New Member
OP
Newbie
Joined
Oct 7, 2021
Messages
3
Trophies
0
Age
23
XP
11
Country
Spain
Hello, I'm developing a graphic engine for my college thesis, a library for the 3ds so everyone can build 3d games.

But I'm starting coding and I have to make sure first of these:

- How to check if there's a memory leak while running the application.

- If there's a memory leak, how can I debug it.

It would be really helpful since I don't want to brick my console or something.

Thanks in advance
 

laramie

Well-Known Member
Member
Joined
Dec 15, 2014
Messages
870
Trophies
0
XP
1,230
Country
United States
Hello, I'm developing a graphic engine for my college thesis, a library for the 3ds so everyone can build 3d games.

But I'm starting coding and I have to make sure first of these:

- How to check if there's a memory leak while running the application.

- If there's a memory leak, how can I debug it.

It would be really helpful since I don't want to brick my console or something.

Thanks in advance
luma3ds has a debugging option but I don't know if it also works on old 3ds's, my new 2ds xl has the option so depends on what hardware you are targeting.
 

antoniorand

New Member
OP
Newbie
Joined
Oct 7, 2021
Messages
3
Trophies
0
Age
23
XP
11
Country
Spain
luma3ds has a debugging option but I don't know if it also works on old 3ds's, my new 2ds xl has the option so depends on what hardware you are targeting.
Must say my target machine is a New 2ds xl so that will be really helpful too.
 

laramie

Well-Known Member
Member
Joined
Dec 15, 2014
Messages
870
Trophies
0
XP
1,230
Country
United States
Must say my target machine is a New 2ds xl so that will be really helpful too.
yeah if you'd like to do both you can but you'd need to make two functions to determine different console types then just sort memory features accordingly. Hope that helps :P
 

ghjfdtg

Well-Known Member
Member
Joined
Jul 13, 2014
Messages
843
Trophies
0
XP
1,952
Country
You can detect memory leaks by overriding malloc() and free() via the linker options "-Wl,--wrap=malloc,--wrap=free". Then make the functions "__wrap_malloc()" and "__wrap_free()". You can then hook every memory allocation/deallocation with these 2 functions and track if everything is getting free'd on exit.

Oh and the real malloc() and free() functions can be accessed by calling "__real_malloc()" and "__real_free()".
 

antoniorand

New Member
OP
Newbie
Joined
Oct 7, 2021
Messages
3
Trophies
0
Age
23
XP
11
Country
Spain
You can detect memory leaks by overriding malloc() and free() via the linker options "-Wl,--wrap=malloc,--wrap=free". Then make the functions "__wrap_malloc()" and "__wrap_free()". You can then hook every memory allocation/deallocation with these 2 functions and track if everything is getting free'd on exit.

Oh and the real malloc() and free() functions can be accessed by calling "__real_malloc()" and "__real_free()".
woah that's actually REAAAALLY helpful, now I'm not actually not scared of breaking anything
 
General chit-chat
Help Users
  • No one is chatting at the moment.
    Psionic Roshambo @ Psionic Roshambo: https://imgur.com/gallery/BiJtKTt