10

I have a C++ DLL that is used for authentication that gets loaded by a Windows service for every login.

In that DLL I use the Windows ADSI function ADsOpenObject() to get a user object from Active Directory.

HRESULT hr = ADsOpenObject(L"LDAP://rootDSE",
                           L"username",
                           L"password",
                           m_dwADSFlags,
                           IID_IDirectorySearch,
                           (void**)&m_DSSearch);

Generally this works since years. But currently I get the error code

-2147024882 (0x8007000E)

which is OUT_OF_MEMORY. When I restart the service that is using my DLL then it runs fine for weeks but then the errors start occuring.

Now I can't find what is out of memory. The task scheduler looks fine and free memory is plenty.
What can I do to fix that?

chue x
  • 18,573
  • 7
  • 56
  • 70
juergen d
  • 201,996
  • 37
  • 293
  • 362
  • Is the ActiveDirectory server out of memory? – Joe Z Dec 11 '13 at 13:52
  • No, it's not. Other applications don't have any problems with it too. – juergen d Dec 11 '13 at 13:53
  • 1
    If I look at the source file "winerror.h" for error 14L, then I see the MessageText as *Not enough storage is available to complete this operation.* Any chance that this is a storage issue? See [here](http://msdn.microsoft.com/en-us/library/windows/desktop/aa746386(v=vs.85).aspx) on why I am using 14L. – chue x Dec 11 '13 at 19:00
  • No, storage is available. – juergen d Dec 11 '13 at 22:23
  • `(void**)&m_DSSearch` is taking the address of the `m_DSSearch` is there a possibility the pointer moves but you don't free that memory ? which might lead to memory leaks overtime ? – a14m Dec 11 '13 at 22:41
  • Are you able to use a third-party tool to diagnose memory allocations? –  Dec 12 '13 at 20:01
  • 1
    What do you mean by "The task scheduler looks fine and free memory is plenty."? Are you looking at system's available RAM or on process's virtual size? – DarkWanderer Dec 18 '13 at 12:13
  • Have you solved this enigma, please ? – Liviu Apr 13 '17 at 08:52

4 Answers4

4

which is OUT_OF_MEMORY.

It is E_OUTOFMEMORY, a COM error code. The description isn't very helpful, this error code tends to be returned for any "out of resources" errors by Microsoft code, not just memory. Could by an internal limit being reached, could be a winapi call that fails.

And it is not necessarily limited to the direct software involved. A mishaving device driver that leaks kernel pool memory can be the indirect source of the mishap for example.

You'll be lucky if you can find something back in the Application event log, look both in the machine that reports the error as well as the domain server. Task Manager might give a clue, add the Handles, GDI Objects, USER Object, Commit size, Page pool and NP Pool columns. Pretty hard to give specific advice beyond this. It is no doubt a leak, quacks loudly like one when you have to restart a machine periodically to recover. Good luck hunting it down.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
2

Are you calling Release on m_DSSearch? Also if you are searching you need to call CloseSearchHandle or AbandonSearch. If you are not doing either of those, you could be slowly leaking memory.

John Bandela
  • 2,416
  • 12
  • 19
0

Your process could fragment the heap to a point so that ADsOpenObject can't find a consecutive piece of memory that is large enough.

You can use VMMap to profile your memory usage: http://technet.microsoft.com/en-us/sysinternals/dd535533

You could try enabling low fragmentation heap: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366750(v=vs.85).aspx

Markus Schumann
  • 7,636
  • 1
  • 21
  • 27
-1

If it is now starting to appear and it wasn't earlier, I would suppose one of two possibilities: it has to do with the time (more specifically the year, a milleniumbug of some kind). Another option would be a problem with 32/64 bit architecture.

Now mind that I don't program C++. But I do know a bit about MS errors (I have worked on a MS helpdesk...)

LaPingvino
  • 2,803
  • 2
  • 18
  • 17