Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

When CEdit::Create returns 0

Posted on 1997-08-12
6
Medium Priority
?
183 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 400 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

886 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