When CEdit::Create returns 0

Posted on 1997-08-12
Last Modified: 2013-11-19
I am developing a program with VC++ 4.0.  My development environment is on a Windows NT 4.0 system.  The program I am developing is being ported over to a Windows 3.11 (Windows For Workgroups) with Win32s installed.  That target machine is a 386 with 8 Megabytes of physical memory, and the virtual memory is set at approximately 16 Megabytes.

Here is the problem.  I am dynamically allocating objects that are derived from the CEdit class.  Eventually, the code calls the base class function CEdit::Create with the appropriate parameters.  On the 386 machine, about 89 to 95 objects get created OK, and then CEdit::Create returns a 0, indicating that the object could not be created.

Do any of your experts out there know under what conditions CEdit::Create will return a 0?  The Microsoft documentation does not provide much help. All I can find so far is that the return value from CEdit::Create is non-zero for success or 0 if it fails, but the documentation does not tell me why or what to look for.  I really could use some help on this

Question by:jimn
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Expert Comment

ID: 1303622
What version of Win32s are you on. There might be limitations for the number of objects being created on Win32s. Does the same application run properly if run on 32 bit version of windows ? Are you sure there are no memory leaks or exception caused during the process of creating other objects befor the CEdit based object ?

Accepted Solution

davmarc earned 100 total points
ID: 1303623
You probably got out of resources. Check the percantage of free USER memory heap at the moment of the failure, Win32s is only a little 32-bit and much 16-bit.

Davide Marcato.

Author Comment

ID: 1303624
Thanks, davemarc.  But, before I grade your answer, I would like to ask you if you could tell me which resources I am out of.  After talking with my collegues, there are apparently two of them.  One is virtual memory.  When objects are allocated with the new operator, the memory returned is from the "heap", and it appears to be virtual memory.  However, when an object is a window, like CEdit, some physical memory is used.  I am using Win32s version 1.3.  To answer the comment from mbhakta, my application runs fine on Windows NT version 4.0.  So, apparently, Windows NT is doing something different when CEdit::Create is called by my application.  That system has 64 MBytes of physical memory, and something like 120 Mbytes of virtual memory.  So far, I haven't hit any memory limits on the NT yet. I am also using Visual C++ version 4.0.  Can you be a little more specific as to what you mean by "out of resources" please?  I will try your suggestion and try to determine the percentage of USER memory at the moment of failure.

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 1303625
Creating CEdit objects requires both RAM (or virtual memory) and USER memory. You can test which one is exhausted sooner by reducing the amount of each one: the Stress utility coming with VC++ is fine for this.

In my opinion you get out of the USER heap: it is one segment of only 64KB in size, and 90 edit controls are quite a lot for it. Try to determine the percentage of free USER heap - its level will reveal this for sure.

Davide Marcato.

Author Comment

ID: 1303626
Thanks, davemarc.  It turns out that the code I am working on did have a place where I could separate the allocation of the CEdit objects and the place where the CEdit object starts to draw the edit box.  By commenting out the place where the object is drawn, all of the object data fits just fine;  no out-of-memory errors (during the time between our emails I was experimenting on my own, and I haven't got around to doing a more detailed heap analysis yet).  So it looks like I have to keep this 64KB of USER heap in mind as I design a work-around to this problem.

Again, thanks for your help.



Expert Comment

ID: 1303627
Glad to help.

Davide Marcato

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java ^ examples 8 75
NotAlone Challenge 20 93
Fibonacci challenge 11 141
Updating statistics with error notification email in SQL server 4 128
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question