Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
HUGE MEMORY LEAK pinpointed!
Grom:
Guys you have to use std::string. That will fix lot's of problems... Specially in that stupid example.
Alturin:
Why aren't you using wxString everywhere anyway?
Either that or as Grom said, use std::string!
Also, maybe someone with the required knowledge could run C::B through valgrind or similar?
byo:
--- Quote from: Alturin on June 20, 2007, 04:49:58 pm ---Why aren't you using wxString everywhere anyway?
Either that or as Grom said, use std::string!
--- End quote ---
wxString CAN NOT be used here because it is used to BUILD proper wxString. And std::string can allocate much more memory than needed. And this code was put into "global functions" because it does some tricky / risky thing and is provided to all developers to prevent them from writing their own (risky/tricky) code. Only because such bug was found in critical function doesn't mean that it's common technique in other parts of code.
--- Quote ---Also, maybe someone with the required knowledge could run C::B through valgrind or similar?
--- End quote ---
That would require some knowledge since wxWidgets would have to compiled with valgrind first. It would be much easier to use wxWidget's built-in memory leak search features.I remember that when using wx with Visual Studio, such things was turned on automatically and gave nice reports at the end of execution.
BYO
TDragon:
--- Quote from: byo on June 20, 2007, 05:08:32 pm ---It would be much easier to use wxWidget's built-in memory leak search features.
--- End quote ---
Just make sure you get rid of:
--- Quote from: Seven C::B source files ---#undef new
--- End quote ---
thomas:
--- Quote ---Why aren't you using wxString everywhere anyway?
--- End quote ---
Well, we could use wxString for that, file.Read(wxStringBuffer(buff, len+1), len); does just that... but it only adds a lot of overhead.
Rather than using a function that allocates buffers and reads data from disk, then makes a copy only to discard it a millisecond later, it would be better to use the FileManager for loading, anyway. This would make use of editors that are already loaded into memory, remove two allocations and memory copies, offer better I/O balancing, and be able to read from URLs.
But for the meantime, this is a nice catch, Rick.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version