README 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. What is this?
  2. This is a small OCaml library for computing size of OCaml values.
  3. It computes count of words used for values, count of values' headers,
  4. maximal depth of values. There are functions to get size of values
  5. in bytes too.
  6. How to use it?
  7. See objsize.mli for documentation.
  8. How to compile/install it?
  9. Run "make <target>" in this directory. Useful make targets are:
  10. - lib : build objsize library
  11. - tests : build tests with fresh-compiled library
  12. - install : install package "objsize" using findlib
  13. - uninstall : uninstall package "objsize"
  14. - clean : clean working directory
  15. - tests-installed : clean working directory and build test programs
  16. assuming you have installed package "objsize" using findlib.
  17. How it works?
  18. C-function walks through values and uses header's field "color"
  19. to mark visited values, then restores original values' "color".
  20. Colors are stored using rle-like compression to decrease memory
  21. usage.
  22. Bugs?
  23. 1. Some constant values (like lists of integers) are
  24. constructed at compile time and placed outside of both heaps,
  25. and size of these values will be returned as 0.
  26. 2. Internal function is not fully tail-recursive,
  27. so generally it uses stack proportionally to the depth
  28. of the value.
  29. There is an optimization to handle long lists and some
  30. other datastructures: when objsize walks through the
  31. structured block, the goto is used instead of recursive
  32. call to walk into the last value that should be visited.
  33. This optimization is not general, and the best solution
  34. would be to use heap memory instead of stack memory to store
  35. "walk path", but I don't need it now (please contribute
  36. if you want).
  37. 3. It requires gnu make. It's possible to write Makefile for
  38. nmake, but I have no MSVC to test. The best solution is
  39. to use ocamlbuild. Either I will write ocamlbuild script
  40. later, or you will contribute it. But it's possible
  41. to build without any makefiles: see original Makefile for
  42. details.
  43. 4. OCaml 3.11 has new implementation of heap. Versions of
  44. objsize >= 0.12 work only with OCaml 3.11 heap, versions
  45. of objsize <= 0.11 work only with OCaml <= 3.10.2 heap.
  46. Runtime failure will be raised if you link objsize >= 0.12
  47. with OCaml < 3.11.
  48. 5. "Bugs" section is too long.
  49. License?
  50. Dual: BSD/GPL.
  51. Changes?
  52. 0.1 - 2007-12-13 - Initial public release.
  53. 0.11 - 2007-12-14 - "configure" made right. Now it works on 64-bits too.
  54. 0.12 - 2009-04-08 - Works with OCaml 3.11, installs with findlib.
  55. 0.13 - 2009-09-01 - Tiny change about so/dll suffix for unix/windows.
  56. 0.14 - 2010-01-26 - Fixing so/dll again.
  57. Some stack usage optimization,
  58. see the modified Bug #2 description.
  59. 0.15 - 2010-04-15 - Fixing bug appeared in 0.14. (thanks to Steven Ramsay)
  60. 0.16 - 2010-08-11 - Fixing bug appeared in 0.14. (thanks to SerP)
  61. Author?
  62. Dmitry Grebeniuk <gdsfh1 at gmail dot com>