Highlighted
Absent Member.
Absent Member.
940 views

[archive] Running out of heapmemory

[Migrated content. Thread originally posted on 20 June 2006]

I have a strange problem. (problems are always strange until you recognise the problem)

We have been forced to reboot the server of a customer every night. After a few hours working perfectly, suddenly the programs won't start. In the eventlog there is a message:

"A desktop heap allocation failed"

The programs are started like this. A program always running is starting other programs at the server with c$run command with a command-line wrun32 and the program name, very simple, but very handy. The programs started in this way always terminate after 1-2 minute's. So there is no other program that the program starting the others running all the time.

After some investigation I have found out, that the error was caused because there were no more heap memory. I realized that somehow we have a memory leak, and running for a period of time caused that there were no more free heap memory.

I have found microsoft's kb: http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q184/8/02.asp&NoWebContent=1
which shows how to increment the heap memory, but somehow I don't think that it is the right solution. I would rather find the memory leak, and that's the reason for making this thread.

Where is my memory leak? Have anybody else got problems with the heap memory? Maybe combined with the c$run command?

I have realized that shutting down my programs releases the memory, but asking acu, they have said, that there is no known memory leaks in the c$run command.


I don't know how my programming can make a leaking memory when they terminate. Terminating a program should empty the used heap memory.

Regards

Steen Jensen
datamann, Denmark
0 Likes
4 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Running out of heapmemory

Is the program that is "always running" running as a Windows service or started through a Windows service?

Desktop heap is not the same as a heap inside a program.

The Windows desktop heap has a fixed size and is global across all processes.

The only time I have ever seen this error is when a Windows service needs to use the CreateProcessAsUser call and insert security information (ACEs) into the desktop security so the process has permission to display its windows. If the service does not remove the security information from the heap or Windows does not allow it to remove it (because the process it started is still running), then the desktop heap fills up over time and only a reboot will clear it.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Running out of heapmemory

Thank for your reply

The program is started from the scheduler and is not running as a service.

I don't think we have any security involved (not as far as I know), and the started programs is terminated, but maybe windows can't se that they are being terminated. But a stop run should stop and clear memory.

But shutting the program, which is running all the time, down clears the heap memory, and that's why I am a little bit suspecious to the c$run command.

Regards

Steen
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Running out of heapmemory

The scheduler is a service, so the programs are running through a service (indirectly).

The reason services must play with the desktop heap is explained in detail in this article: Why Do Certain Win32 Technologies Misbehave in Windows NT Services?

Only Acucorp can say whether or not C$RUN does anything with the desktop heap.

If they say it does not, then you may want to try disabling the scheduled task you have set up and schedule it using the "AT" command from a Command Prompt (type "AT /?" for the syntax).

When you schedule the command through AT, it runs it in the System Account which has access to the desktop. The downside though is that the program will not be able to access any network drives or shares, so if it needs them, this will not work.

(Note: If this does end up making a difference - and I'm not saying it will, it's just a shot in the dark - you must not use the Scheduled Tasks applet to make any changes to the task, such as time, etc. because it will require you to give it a login and password to use - it does not know to schedule something to run in the System Account. To make any changes, you will need to delete the task and reschedule it with the AT command.)
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Running out of heapmemory

But a stop run should stop and clear memory.

But also keep in mind that the desktop heap is not memory inside the process. The desktop heap is a global area of memory in Windows itself, and memory allocated there can persist across processes. The kernel manages it, not the process.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.