Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ADsOpenObject() returns -2147024882 (0x8007000E) -> OUT_OF_MEMORY

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?

like image 387
juergen d Avatar asked Dec 06 '13 09:12

juergen d


2 Answers

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.

like image 141
Hans Passant Avatar answered Oct 24 '22 02:10

Hans Passant


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.

like image 20
John Bandela Avatar answered Oct 24 '22 04:10

John Bandela