From: sime AT fly DOT cc DOT fer DOT hr (S. Mikecin) Newsgroups: comp.os.msdos.djgpp Subject: Re: QEMM & DJGPP new/delete bug? Date: 26 Nov 1996 12:14:12 GMT Organization: FER, Croatia Lines: 86 Distribution: inet Message-ID: <57emuk$qog@bagan.srce.hr> References: <32969DB7 DOT 3128 AT nlc DOT net DOT au> Reply-To: sime AT fly DOT cc DOT etf DOT hr NNTP-Posting-Host: fly.cc.etf.hr Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp shaman AT nlc DOT net DOT au wrote: : I've come across an interesting "bug". I don't know what is causing it : exactly. Actually, I wouldn't have a clue what is causing it. Is this a : bug in my code? A problem with DJGPP? My memory manager? I've seen this : before, but this is the first time I've seen it happen with a small : enough piece of code to nail it to new and delete. If it's a bug in : DJGPP, is it fixed in 2.01? PLEASE REPLY BY EMAIL. : WHAT I'M DOING: Allocating large amounts of ram (4megs+) for zbuffers : and frame buffers. : THE SYMPTOMS: Simple test program runs okay in a totally clean boot and : CWSPMI, but crashes if run more than a couple of times under QEMM 8.0 : and CWSDPMI. QDPMI is not loaded. QEMM is in "ON" mode, not AUTO. It : crashes faster if I also run ramdisk (~3M) and smartdrv(~2M). I have an : AMD486DX2/80, DOS 6.22 and 16 megs of ram. It also can't allocate any : more than half of the available ram, even though I'm not running WIN95, : and I'm not allocating it in one chunk. (I'm allocating in just over 1 : meg pieces). : METHOD: I wrote simple classes for the BUFFER and ZBUFFER types, which : are self allocating arrays of unsigned longs. (Source for ctors and : dtors below). The program allocates space for them using new, then : erases them using delete as would be normal. : SOURCE: : // typedef unsigned long ulong; : // ulong* data; : // ulong** ytable; : BUFFER::BUFFER( ulong w, ulong h ) : { : _width = w; _height = h; : data = new ulong [_width*_height]; // Alloc memory for bitmap : ytable = new ulong* [_height]; // Then allocate for y table. : // precalc y lookup table. : ulong* prev = data; : for ( int i = 0; i < _height; i++ ) : { : ytable[i] = prev; : prev += _width; // increment pointer for next line. : } : } : ZBUFFER::ZBUFFER() is exactly the same as BUFFER::BUFFER() : BUFFER::~BUFFER() : { : delete ytable; : delete data; : } : ZBUFFER::~ZBUFFER is the same. : This is the part in the test program: : ... : BUFFER* test = new BUFFER( 1024, 1024 ); // 1 meg. : delete test; : ... : -- : . . . the Lord Shaman : : ------------------------------------------------------------------ : http://www.nlc.net.au/~shaman or mailto:shaman AT nlc DOT net DOT au : : ------------------------------------------------------------------ I have QEMM 8.0 & CWSDPMI v3, ON 486DX4/120 with 12Megs of RAM (2xDiskCache+1xRAMDisk) and didn't have any problems with it. I allocated all memory and more (virtual). Actually my QEMM was patched with 800to801.exe so the version is actually 8.01. -- <2nd E-mail: simun DOT mikecin AT fer DOT hr >