Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

When CEdit::Create returns 0

Posted on 1997-08-12
6
Medium Priority
?
182 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
[X]
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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

721 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