How to debug Rtl functions memory leak?

Hello friends, i have been running into a problem of memory leak in my filter driver. After running the system for long hours (12+ hours) the system starts running into out of resources. I enabled pooltagging and checked and found Strg which is the default tag of Rtl functions is consuming all the non paged memory used for Unicode Strings. I enabled driver verifier but was unable to find this memory leak.Is there any easy way to know which Rtl function is causing this leak ? rather than walkthrough manually? Thanks for your time.

Wrap all string Rtl functions in your code with the wrappers, which will insert some tracking info to the allocated pool blocks - usually source file name and line number where the allocation was made, and also link all these pool blocks to the global list.

Trivially done with #define, and is the usual way how memory leak detectors are built.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntfsd…
> Hello friends, i have been running into a problem of memory leak in my filter driver. After running the system for long hours (12+ hours) the system starts running into out of resources. I enabled pooltagging and checked and found Strg which is the default tag of Rtl functions is consuming all the non paged memory used for Unicode Strings. I enabled driver verifier but was unable to find this memory leak.Is there any easy way to know which Rtl function is causing this leak ? rather than walkthrough manually? Thanks for your time.
>

thx Maxim .

Even doing this will not assure you that you will correctly find the memory
leak.
Some memory blocks might be used for indefinite periods of time, and maybe
you assumption that the Rtl functions are of fault might be wrong.
You can actually have code paths that return error code and do not free the
memory allocated until that point, so the usage of the Rtl functions is
correct.
There can be a lot of scenarios like this, so I would suggest, if the
verifier with special pool enabled did not pumped any bugchecks, to debug
the code manually.

With respect,
Gabriel Bercea

GaMiTech Software Development
Mobile contact: (+40)0740049634
eMail: xxxxx@gmail.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Saturday, January 24, 2009 6:11 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] How to debug Rtl functions memory leak?

Wrap all string Rtl functions in your code with the wrappers, which will
insert some tracking info to the allocated pool blocks - usually source file
name and line number where the allocation was made, and also link all these
pool blocks to the global list.

Trivially done with #define, and is the usual way how memory leak
detectors are built.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntfsd…
> Hello friends, i have been running into a problem of memory leak in my
filter driver. After running the system for long hours (12+ hours) the
system starts running into out of resources. I enabled pooltagging and
checked and found Strg which is the default tag of Rtl functions is
consuming all the non paged memory used for Unicode Strings. I enabled
driver verifier but was unable to find this memory leak.Is there any easy
way to know which Rtl function is causing this leak ? rather than
walkthrough manually? Thanks for your time.
>


NTFSD is sponsored by OSR

For our schedule debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

IIRC some of the functions allocate and return pool to the caller, to be
de-allocated by the caller - using RtlFreeUnicodeString. Which particular
functions do you use?

wrote in message news:xxxxx@ntfsd…
> Hello friends, i have been running into a problem of memory leak in my
> filter driver. After running the system for long hours (12+ hours) the
> system starts running into out of resources. I enabled pooltagging and
> checked and found Strg which is the default tag of Rtl functions is
> consuming all the non paged memory used for Unicode Strings. I enabled
> driver verifier but was unable to find this memory leak.Is there any easy
> way to know which Rtl function is causing this leak ? rather than
> walkthrough manually? Thanks for your time.
>

Thx for all the experts here. Your suggestions really helped me in solving this problem. There was a memory leak with RtlUnicodeStringToAnsiString which i was not freeing up using RtlFreeAnsiString. Manual walkthrough the code helped me to get this fixed.Thanks once again…