Hi all,

I am trying to profile my application which has its own memory management
functions, or you can say that my application has its own memory pool.
How my application handle memory allocation:-
- At start up, the application ask the OS to allocate a huge block of memory
at once (i.e. adjacent(consecutive) memory locations) using normal OS memory
allocation functions. like malloc or mmap
- then I create a stack of nodes, each node holds a pointer to a position in
this memory block. Such that, the range of bytes in the memory block between
2 successive nodes in the stack are constant.

- In other words; if my huge memory block contains 100 consecutive bytes,
and if my stack contains 5 nodes, then the distance between 2 nodes in the
stack is 20 byte. i.e. the 1st node will point to byte_0, 2nd node will
point to byte_20, ...

- Then I have implemented my own malloc function and named it as
"myown_malloc"
- the function "myown_malloc" works as follows:
-- When it is the 1st time to allocate memory using myown_malloc, it will
return the pointer of the 1st node in that stack and mark this node to be
reserved (using some flags). This means the 1st 20 Bytes in my huge memory
block is not reserved.
-- Then, when never I ask myown_malloc to allocate memory, it checks the 1st
unreserved node in the stack and return its pointer.
-- When no nodes in the stack are unreserved, then ask the OS to allocate a
new huge consecutive memory block, and extend and add new nodes to the stack
to access the new memory block.

You can find more information about this memory pool model here, but you do
not need to read it:
http://www.codeproject.com/KB/cpp/MemoryPool.aspx

Now, come to my questions;
I would like to use massif profile memory allocation:-
if I would use the option --alloc-fn=myown_malloc, what is the expected
result?
Notice that myown_malloc doesn't make physical allocation, it just return a
pointer to a range of bytes.
How massif will behave in this case?

The 2nd question is related to the new tool DHAT (dynamic heap allocation
analysis tool).
If I would use DHAT, I think it would be more accurate as according to my
understanding, the tool just measure number of allocated memory from the OS
point of view. It is not interested in allocation functions itself.
Does this means DHAT is better than massif when profiling proprietary memory
pools?

Thank you for reading these weird details, I will really appreciate any
comments from you.
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to