memory leak in services

  • Thread starter Thread starter zap
  • Start date Start date
Z

zap

Hi, developers.

I have not finded information in MSDN, and decide to ask you here.

As I understand SCM (Service Control Manager) runs an application and waits
for command "start service". After it receives this command, it starts
new thread by way "CreateThread".

But if I start new thread by "CreateThread", I don't release thread data
(THREAD_DATA).
What I must do? - create new thread by _beginthread and work there or
terminate that thread by _endthread?

with best regards,
zap
 
zap said:
Hi, developers.

I have not finded information in MSDN, and decide to ask you here.

As I understand SCM (Service Control Manager) runs an application and waits
for command "start service". After it receives this command, it starts
new thread by way "CreateThread".

But if I start new thread by "CreateThread", I don't release thread data
(THREAD_DATA).
What I must do? - create new thread by _beginthread and work there or
terminate that thread by _endthread?

As far as I understand it, ExitThread reclaims resources (for a thread
that returns), but using _beginthread the executable must be linked
with LIBCMT.LIB, i.e. a 'C' program. Incidentally, _endthread (if
the thread returns) reclaims resources and then calls ExitThread
automatically. I've used _beginthread.
 
I'm sorry for my bad English.

I just want to say, that threads of service for ServiceMain aren't created
by "_beginthread" function of my RTL. That is why after ServiceMain
returns, RTL couldn't reclaim its resources (i.e. THREAD_INFO).
 
Back
Top