Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Class Limit?

Status
Not open for further replies.

Supernat03

Programmer
Apr 30, 2003
206
US
Hello All,

I have a large class defined in BC++ Builder 4 Pro. I just added 3 boolean variables to the class and it crashes when loading, compiles fine. I removed one of the booleans and it runs like it should. I also removed a different one and re-enabled the one that was commented out, and THAT works fine! I've not seen this before. It's like I've reached a maximum memory space for that class or something. Does anyone know??

Thanks!
Chris
 
Also, I noticed it produces a link failure each time, saying that it cannot do an incremental link, and must perform a full link. It also happens when I write extra code. For instance, I had a set of braces that did nothing, just {}, and it crashed. When I removed them, it runs fine. Something tells me I'm at a limit...

Chris
 
Classes have not a memory limit, I have created components really big and I never got problems with that.

Are u initializing the booleans variables in the class?



---LastCyborg---
 
This class is really really big. hehe. I forgot to mention it's a visual component. All I did was add the statement "boolean NewBool;" to the .h file, and it crashes when it runs. When I take that out, it runs. Or if I add a set of empty braces "{}" anywhere in the code, it crashes. I just cleaned the code up a little (reduced it's size), and added my needed code, and it works for now.

Chris
 
How big is this class?
How many lines of code & what size is it when compiled?
 
The class is 3381 lines, object file is 145 kb.

The actual program where I drop the VCL component on the forms is 10536 lines. It's executable size is 2.99 MB.

Chris
 
That shouldn't be a big deal, BCB should be able to handle that with out a problem.
I was thinking you were talking about something 10-100 times bigger.
 
How much memory (RAM), virtual memory, and disk space do you have?


James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
Haha, 100 times bigger and I could replace Windows with whatever OS I was writing. Anyway, I have a dual PIII 800, with 1.5 GB ram. I am, however, using BCB 4.0. It's probably just some bug. Oh well, I've worked around it now, so hopefully I won't see it again. :)

Chris
 
Sorry I didn't answer your questions entirely.

James, there are 40 gigs worth of free space. 780 MB of virtual memory free as well.

Chipper, I am caching precompiled headers.

Here's some additional info about the problem just in case someone does recognize it:

The paint method on the component is running once every 500 ms and paints 4 separate bitmaps, as needed, and combines them.
The program is compiled without dynamic RTL.
The total lines compiled at the end is 590,000.
I've tried both full debug and release compiles.
I've tried all of the instruction sets (386 to pent pro)
It only crashes after running. The compile is fine.

Thanks!
Chris
 
Pure speculation here, but it sounds like maybe an ODR (One-Definition-Rule) problem.

That means you've compiled one source file with the "old" header file, changed the header, then compiled another source file with the new header. Theoretically, this should be caught at link time, but for whatever reason (probably time concerns), lots of linkers don't make sure every definition of a single class is the same.

The result is, of course, that you have a program where a given class has more than one definition, so using it is always ambiguous. I can't speak from experience, but I'd imagine that would cause a program crash.

I'd imagine Borland's build process would detect the change and make sure you recompile the old source file before linking it, but possibly not.

The same thing could occur because of precompiled headers; the old source code could have been compiled with the old precompiled header, and the new one with the new precompiled header.

Again, I'd hope Borland's build process could deal with that, but there could be a bug.

Those are the things I'd check about.
 
I tried not caching headers, but it didn't help. However, I think I've figured it out. It's a 3 MB exe file size limit in the final compile. It'll crash everytime, just before it hits 3MB. So I tried building with runtime packages. The output file size drops to about 2.5MB and it runs fine. Go figure!!

Chris
 
are the graphics bloating the executable. if this is the case and you must have the images in a compiled format you could put them into a dll maybe. kinda split the program up to smaller parts. this may be necessary because you dont seem to have a lot of room for growth codewise or graphics wise. even with the new compile.

tomcruz.net
 
I came to the same conclusion as well. Need to split it up. It's mostly the vcl component (which produces a bar graph of sorts), yes. For now, I'm just going to compile with runtime dll's, until I get time to export the class to a dll.

I'm not familiar with the process. How would I export a component (or package even) to a dll?

Thanks,
Chris
 
I would have the dlls to be a resource container for the graphics and such. As for implementing your class into a dll I personally dont have much experience with that But it should not be much different than loading a dll with functions and variables. You might try to do the initializing and creating the object from the dll and them retrieving the pointer from your mainform.

The help files have a very good example of creating a dll along with doing the VCL thing from the same. You might just have to expand upon that. look for "creating a dll" in the help files

tomcruz.net
 
There aren't really any hard-coded graphics persay, I actually draw the graphics on the fly with standard functions, like rectangle, lineto, etc. So that would rule out using resources, right?

Chris
 
I dont know about adding a component but the class that you are implementing could probably be inserted into the dll as itself and just bypass the component thing.

check out also

"Creating DLLs containing VCL components"

in the help file

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top