blob: 7bba12201e0ee31d69002094d49cc6eea8412f09 [file] [log] [blame]
Austin Schuh745610d2015-09-06 18:19:50 -07001--- COMPILING
2
3This project has begun being ported to Windows, only tcmalloc_minimal
4is supported at this time. A working solution file exists in this
5directory:
6 gperftools.sln
7
8You can load this solution file into VC++ 7.1 (Visual Studio 2003) or
9later -- in the latter case, it will automatically convert the files
10to the latest format for you.
11
12When you build the solution, it will create a number of unittests,
13which you can run by hand (or, more easily, under the Visual Studio
14debugger) to make sure everything is working properly on your system.
15The binaries will end up in a directory called "debug" or "release" in
16the top-level directory (next to the .sln file). It will also create
17two binaries, nm-pdb and addr2line-pdb, which you should install in
18the same directory you install the 'pprof' perl script.
19
20I don't know very much about how to install DLLs on Windows, so you'll
21have to figure out that part for yourself. If you choose to just
22re-use the existing .sln, make sure you set the IncludeDir's
23appropriately! Look at the properties for libtcmalloc_minimal.dll.
24
25Note that these systems are set to build in Debug mode by default.
26You may want to change them to Release mode.
27
28To use tcmalloc_minimal in your own projects, you should only need to
29build the dll and install it someplace, so you can link it into
30further binaries. To use the dll, you need to add the following to
31the linker line of your executable:
32 "libtcmalloc_minimal.lib" /INCLUDE:"__tcmalloc"
33
34Here is how to accomplish this in Visual Studio 2005 (VC8):
35
361) Have your executable depend on the tcmalloc library by selecting
37 "Project Dependencies..." from the "Project" menu. Your executable
38 should depend on "libtcmalloc_minimal".
39
402) Have your executable depend on a tcmalloc symbol -- this is
41 necessary so the linker doesn't "optimize out" the libtcmalloc
42 dependency -- by right-clicking on your executable's project (in
43 the solution explorer), selecting Properties from the pull-down
44 menu, then selecting "Configuration Properties" -> "Linker" ->
45 "Input". Then, in the "Force Symbol References" field, enter the
46 text "__tcmalloc" (without the quotes). Be sure to do this for both
47 debug and release modes!
48
49You can also link tcmalloc code in statically -- see the example
50project tcmalloc_minimal_unittest-static, which does this. For this
51to work, you'll need to add "/D PERFTOOLS_DLL_DECL=" to the compile
52line of every perftools .cc file. You do not need to depend on the
53tcmalloc symbol in this case (that is, you don't need to do either
54step 1 or step 2 from above).
55
56An alternative to all the above is to statically link your application
57with libc, and then replace its malloc with tcmalloc. This allows you
58to just build and link your program normally; the tcmalloc support
59comes in a post-processing step. This is more reliable than the above
60technique (which depends on run-time patching, which is inherently
61fragile), though more work to set up. For details, see
62 https://groups.google.com/group/google-perftools/browse_thread/thread/41cd3710af85e57b
63
64
65--- THE HEAP-PROFILER
66
67The heap-profiler has had a preliminary port to Windows but does not
68build on Windows by default. It has not been well tested, and
69probably does not work at all when Frame Pointer Optimization (FPO) is
70enabled -- that is, in release mode. The other features of perftools,
71such as the cpu-profiler and leak-checker, have not yet been ported to
72Windows at all.
73
74
75--- WIN64
76
77The function-patcher has to disassemble code, and is very
78x86-specific. However, the rest of perftools should work fine for
79both x86 and x64. In particular, if you use the 'statically link with
80libc, and replace its malloc with tcmalloc' approach, mentioned above,
81it should be possible to use tcmalloc with 64-bit windows.
82
83As of perftools 1.10, there is some support for disassembling x86_64
84instructions, for work with win64. This work is preliminary, but the
85test file preamble_patcher_test.cc is provided to play around with
86that a bit. preamble_patcher_test will not compile on win32.
87
88
89--- ISSUES
90
91NOTE FOR WIN2K USERS: According to reports
92(http://code.google.com/p/gperftools/issues/detail?id=127)
93the stack-tracing necessary for the heap-profiler does not work on
94Win2K. The best workaround is, if you are building on a Win2k system
95is to add "/D NO_TCMALLOC_SAMPLES=" to your build, to turn off the
96stack-tracing. You will not be able to use the heap-profiler if you
97do this.
98
99NOTE ON _MSIZE and _RECALLOC: The tcmalloc version of _msize returns
100the size of the region tcmalloc allocated for you -- which is at least
101as many bytes you asked for, but may be more. (btw, these *are* bytes
102you own, even if you didn't ask for all of them, so it's correct code
103to access all of them if you want.) Unfortunately, the Windows CRT
104_recalloc() routine assumes that _msize returns exactly as many bytes
105as were requested. As a result, _recalloc() may not zero out new
106bytes correctly. IT'S SAFEST NOT TO USE _RECALLOC WITH TCMALLOC.
107_recalloc() is a tricky routine to use in any case (it's not safe to
108use with realloc, for instance).
109
110
111I have little experience with Windows programming, so there may be
112better ways to set this up than I've done! If you run across any
113problems, please post to the google-perftools Google Group, or report
114them on the gperftools Google Code site:
115 http://groups.google.com/group/google-perftools
116 http://code.google.com/p/gperftools/issues/list
117
118-- craig
119
120Last modified: 2 February 2012