This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Problems allocating memory with C++ new operator on eCos 1.3.1


Andrew:
 
Thanks for your comments. I had a feeling this was a configuration
issue, but I missed the option for changing the size of the dynamic
memory pool when I looked through the configuration tool. I checked the
.ecc file as you recommended and found the option. 
 
You have a good memory! The default size is only 16K. I suppose that
increasing this value should solve my problem, provided that I ensure
that that amount that I have allocated at any time is less than this
value. Would you agree with this?
 
I'm not sure why my test program chokes on different stack sizes. Since
I was only doing a test, I didn't check the return value of the pointer.
However, I didn't use the pointer afterwards. My test simply launches a
main thread, uses the new operator to allocate 16356 bytes and then
enters a continuous loop where I toggle an I/O line (to check that the
program hasn't crashed).  I didn't bother to narrow down the range of
usable stack sizes. When allocating 16356 bytes, it worked with stack
sizes of 5000 and 3000 bytes, but failed with 2000, 7500 and 10000
bytes. 
 
Thanks for your help, 
 
CHRIS.

	-----Original Message----- 
	From: Andrew Lunn 
	Sent: Fri 11/2/2001 11:12 AM 
	To: Chris Sekula 
	Cc: ecos-discuss@sources.redhat.com 
	Subject: Re: [ECOS] Problems allocating memory with C++ new
operator on eCos 1.3.1
	
	

	On Fri, Nov 02, 2001 at 10:55:46AM -0500, Chris Sekula wrote:
	> I have been having some problems allocating memory with the
C++ new
	> operator. We are using the Cirrus Logic EP7312 chip and eCos
1.3.1. We
	> have used the patch provided by Cirrus Logic so that we can
enable the
	> 7212 template to work on the 7312. Our board has 16 Megs of
RAM.
	> 
	> I launched a main thread with a stack size of 5000 bytes. In
this
	> thread, when I try to allocate more than 16356 bytes, my
program hangs.
	> The test program works with allocations less than this amount.
I played
	> with a few different stack sizes as well, keeping the dynamic
allocation
	> at 16356 bytes. The allocation doesn't work when a stack size
of 7500
	> bytes(or more) or 2000 bytes (or less) is used.
	> 
	> Does eCos put a narrow limit on the size of the heap? How can
I get
	> around this problem?
	
	Its a long time since i used 1.3.1 so you should double check
	everything i say!
	
	The stack size should not have any affect on the heap. I think
you are
	seeing a side affect here. When its going wrong its corrupting
your
	stack. It only hits something vital when your stack is < 2000 or
>
	7500.
	
	Are you checking the return from new. Does it fail when you ask
for
	more than 16K or are you just blindly using the return value
which may
	be a null pointer and so you then corrupt something in low
memory.....
	
	1.3.1 does not have the dynamic heap code if i remember
correctly. Its
	implemented using a variable size memory pool. You can change
the size
	of the pool using the CDL in ecos.ecc. I have a vague
recollection the
	default is 16K! What size are you using?
	
	     Andrew
	


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]