README_windows.txt 5.5 KB

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