How to do things
AI Noob vs. Pro

List biggest files
List newest files
Show subdir sizes
Search in files
Replace word in files
List dir differences
Send files in LAN

Free Open Source:

Swiss File Knife

a command line
multi function tool.

remove tabs
list dir sizes
find text
filter lines
find in path
collect text
instant ftp or
http server
file transfer
send text
patch text
patch binary
run own cmd
convert crlf
dup file find
md5 lists
fromto clip
hexdump
split files
list latest
compare dirs
save typing
trace http
echo colors
head & tail
find classes
dep. listing
speed shell
zip search
zip dir list

Depeche View
Source Research
First Steps

windows GUI
automation

the d3caster
java game engine

command line
file encryption

free external tools,
zero install effort,
usb stick compliant:

zip and unzip
diff and merge
reformat xml
reformat source

java sources

thread creation

cpp sources

log tracing
mem tracing
hexdump
using printf

articles

embedded
stat. c array
stat. java array
var. c array
var. java array
view all text
as you type
surf over text
find by click
quick copy
multi view
find nearby
fullscreen
bookmarks
find by path
expressions
location jump
skip accents
clip match
filter lines
edit text
highlight
load filter
hotkey list
receive text
send in C++
send in Java
smooth scroll
touch scroll
fly wxWidgets
fly over Qt
search Java

 

How to trace memory leaks C++ with a few lines of code:
free source code for instant use in windows projects.

SFK The Book - New Productivity Heights.

starting point: let's say we have a simple C++ program like this:

#include <stdio.h>
#include <string.h>

char *joinStrings(char *p1, char *p2)
{
   int nlen1 = strlen(p1);
   int nlen2 = strlen(p2);
   char *pres = new char[nlen1+nlen2+10];
   strcpy(pres, p1);
   strcat(pres, p2);
   return pres;
}

int main(int argc, char *argv[])
{
   printf("string concatenation test:\n");
   char *psz1 = "hello";
   char *psz2 = "world";
   char *pszj = joinStrings(psz1, psz2);
   printf("result: %s\n", pszj);
   return 0;
}
this program seems to run without problems, producing this output:
   string concatenation test:
   result: helloworld
however we don't really know if all memory has been freed.
 

to find out, download memdeb.cpp from here and extend the example like this:

#include <stdio.h>
#include <string.h>

#include "memdeb.cpp"

char *joinStrings(char *p1, char *p2)
{
   int nlen1 = strlen(p1);
   int nlen2 = strlen(p2);
   char *pres = new char[nlen1+nlen2+10];
   strcpy(pres, p1);
   strcat(pres, p2);
   return pres;
}

int main(int argc, char *argv[])
{
   printf("string concatenation test:\n");
   char *psz1 = "hello";
   char *psz2 = "world";
   char *pszj = joinStrings(psz1, psz2);
   printf("result: %s\n", pszj);

   listMemoryLeaks();

   return 0;
}
now, the program produces this output:
string concatenation test:
result: helloworld
MEM LEAK: adr 32075ch, size 20, alloc'ed in test.cpp 10
[SMEMDEBUG: 1 new's, 0 delete's, 0 errors, 1 leaks]
if you want to integrate the memory tracing into a project with several .cpp files, include it everywhere, defining in most files
#define MEMDEB_JUST_DECLARE
before the include. only in one .cpp file, leave out this define. it should also be easy to split memdeb.cpp into a .hpp and .cpp, as the code is rather short.

NOTE:

  • as all free stuff, SFK memory tracing comes without any warranty
  • it eats some performance when used with many memory objects
  • it is not thread safe
and if you integrate this into a project, always do it in a way which allows (de)activation through a define, e.g.
   #ifdef WITH_MEMORY_TRACING
     #include "memdeb.cpp"
   #endif

SFK memory tracing is used to track memory leaks in the text file processor swiss file knife. read more about sfk here.

Download the free Depeche View Lite Text Search Tool