memory leak in services

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
 
A

Alan Illeman

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.
 
Z

zap

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top