Duplicate allocation number

wo omla
  • wo omla
    wo omla

    I periodically call LogAllocatedBlocksToFile for a specifiec allocation group.
    Sometimes I see the same allocation number twice, with a different pointer and stack etc.

    Is this normal behaviour? I thought that allocation number is unique.

  • Hi,

    Allocation numbers are unique per process. Every time you call GetMem the number is bumped and stored in the block header. Only when you reallocate a block does it keep the old allocation number.

    Note that every time the application starts that the allocation numbers start from 0, so if you're not deleting the log file between runs you will see duplicate allocation numbers.

    Also, allocation numbers are stored in a Cardinal, so will wrap back to 0 once it hits 4 billion. It usually takes a while for that to happen though.

    Best regards,

  • wo omla
    wo omla

    Hi Pierre,

    Thanks for your answer.

    I now discovered that, although I have 'ClearLogFileOnStartup' defined, the log is cleared during initialization, not finalization. So when I call LogAllocateeBlocksToFile, I create the log file. Than during finalization, the leaks are added. This creates entries with double allocation numbers.

    When I call LogAllocatedBlocksToFile, I basically want to dump the contents to a specific file. I don't think that SetMMLogFileName is thread safe, is it?

    Thanks again.