Solved

When CEdit::Create returns 0

Posted on 1997-08-12
6
175 Views
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
one.

Thanks.
0
Comment
Question by:jimn
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:mbhakta
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 ?
0
 
LVL 4

Accepted Solution

by:
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.
0
 

Author Comment

by:jimn
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.

Thanks.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:davmarc
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.
0
 

Author Comment

by:jimn
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.

Jim

0
 
LVL 4

Expert Comment

by:davmarc
ID: 1303627
Glad to help.

Davide Marcato
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 53
Tab names are off by one 5 53
wait notify demo infinite loop 3 94
How to convert MFC::CString to UTF8 wchar_t* 10 137
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now