Re: CFrameWnd::LoadFrame cause insufficient memory error
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Thu, 09 Jun 2005 11:50:43 -0400
No, you've clearly stated the situation: when a service runs a program, it has a problem.
When you run the program from ordinary user space, you don't have a problem. This leads to
the inevitable conclusion that you should not be running such an app as a service. SInce
you are using a GUI app (otherwise LoadFrame would not be called), you are basically
begging for trouble running it from a service.
'Out of memory' almost always means either 'uninitialized variable' or 'failure to test a
return value to see if it is valid'. Rarely does it actually mean you have run out of
memory. It means that some attempt at allocation used a value which is garbage, but a very
large garbage value. So some allocation which uses that as a count fails, and the message
follows.
What has most likely happened is that because it is a service, some initialization, which
works as an ordinary user app but which fails when run as a service, is not performed.
Therefore, some variable is left improperly initialized. One example I've seen of this is
trying to open a file without bothering to check if the open succeeded, for example. The
LocalSystem account did not have the privileges necessary to open the file, but since the
programmer "knew" that the open could never fail, no check was made for a successful
return. Presumably it is not something this simple because you say it also works under
LocalSystem. But look for related issues.
If you are launching a GUI app, you need to rethink why you are doing it at all. Services
do not generally have GUIs (and if they do, the GUI is not supported by MFC; look for the
MSDN article on putting a GUI into a service).
Since you can obviously look at this with the debugger, doing some single-stepping into
MFC would be very productive.
joe
On Thu, 9 Jun 2005 10:21:25 +0200, "Andrea Biagini" <andrea.biagini@xxxxxxxxx> wrote:
>But the service calls an .exe with a command line parameter, and the .exe
>cause the error.
>If I call the .exe with a link, using the same command line parameter, all
>works well.
>All works well if the service use LocalSystem user, too.
>
>How can be an issue of uninitialized variable?
>
>"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> ha scritto nel messaggio
>news:dv5ea1lmspcnkfdjjjl6vp69iujaogrmm8@xxxxxxxxxx
>> Not enough information. Single-step through it. Usually it means that
>> somewhere there is
>> an uninitialized variable so somebody thinks there is a length 0xcccccccc.
>> LoadFrame is
>> far too high-level to tell what is going wrong.
>>
>> It is not an issue of memory assignment; it is an issue of some variable
>> not being
>> properly initialized. Since services rarely if ever use user interfaces,
>> there may have
>> been an earlier failure that left something uninitialized.
>> joe
>>
>> On Wed, 8 Jun 2005 08:40:42 +0200, "Andrea Biagini"
>> <andrea.biagini@xxxxxxxxx> wrote:
>>
>>>Hi,
>>>I have a windows service that locally calls an .exe application
>>>(creating a new process with CreateProcess API);
>>>this application must access to a protected directory (only one
>>>user can access it).
>>>Normally a windows service is associated with LocalSystem
>>>user; so when it calls .exe application, it can't access to
>>>the directory. To solve this problem, i have associated my
>>>service to the account that can access that directory, but
>>>when it calls .exe application, an instruction like
>>>
>>>pFrame->LoadFrame(IDR_MAINFRAME,
>>> WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
>>> NULL);
>>>
>>>(contained into .exe) fails, with error "Insufficient memory".
>>>
>>>Another try i've made is creating a link to .exe that call to the
>>>application using
>>>the account that can access to the protected directory. All works well.
>>>It seems that the same user associated to a windows service and to a link
>>>has different memory assignation.
>>>
>>>Thanks to all that can help me.
>>>
>>>Andrea.
>>>
>>
>> Joseph M. Newcomer [MVP]
>> email: newcomer@xxxxxxxxxxxx
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: CFrameWnd::LoadFrame cause insufficient memory error
- From: Andrea Biagini
- Re: CFrameWnd::LoadFrame cause insufficient memory error
- References:
- CFrameWnd::LoadFrame cause insufficient memory error
- From: Andrea Biagini
- Re: CFrameWnd::LoadFrame cause insufficient memory error
- From: Joseph M . Newcomer
- Re: CFrameWnd::LoadFrame cause insufficient memory error
- From: Andrea Biagini
- CFrameWnd::LoadFrame cause insufficient memory error
- Prev by Date: How to sort CListCtrl on checkbox column?
- Next by Date: Re: Timer
- Previous by thread: Re: CFrameWnd::LoadFrame cause insufficient memory error
- Next by thread: Re: CFrameWnd::LoadFrame cause insufficient memory error
- Index(es):
Relevant Pages
|
Loading