AcDbDatabase constructor failed why?

AcDbDatabase constructor failed why?

Anonymous
Not applicable
767 Views
10 Replies
Message 1 of 11

AcDbDatabase constructor failed why?

Anonymous
Not applicable
AcDbDatabase* db = new AcDbDatabase(Adesk::kFalse, Adesk::kTrue );

is the only line of code. I amk trying to instantiate the Da6tabase object toopen adrawing.



I get heap errors everytime.

Can anyone help

Nick
0 Likes
768 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
Nick:

> I get heap errors everytime.

You need to delete the database after you're finished with it. 🙂
--
Owen Wengerd
President, ManuSoft ==> http://www.manusoft.com
VP Americas, CADLock, Inc. ==> http://www.cadlock.com
0 Likes
Message 3 of 11

Anonymous
Not applicable
how? should I open it with a different object first.

I set it to null, is there a delete method or something?
0 Likes
Message 4 of 11

Anonymous
Not applicable
After running this code the db pointer is still NULL?

Out of memory i think...

nick5454 wrote:
> AcDbDatabase* db = new AcDbDatabase(Adesk::kFalse, Adesk::kTrue );
>
> is the only line of code. I amk trying to instantiate the Da6tabase object toopen adrawing.
>
>
>
> I get heap errors everytime.
>
> Can anyone help
>
> Nick
0 Likes
Message 5 of 11

Anonymous
Not applicable
try

delete db;



wrote in message news:4838459@discussion.autodesk.com...
how? should I open it with a different object first.

I set it to null, is there a delete method or something?
0 Likes
Message 6 of 11

Anonymous
Not applicable
actually the pointer is valid but somewhere after is creates AcDbDatabase is fails with the heap.
0 Likes
Message 7 of 11

Anonymous
Not applicable
looks like allocRawMem fails.
0 Likes
Message 8 of 11

Anonymous
Not applicable
so it creates the object. then before it finished with the constructor it calls delete for some reason and bombs.

Please someone help
0 Likes
Message 9 of 11

Anonymous
Not applicable
try this:

AcDbDatabase* db = NULL;
try
{
db = new AcDbDatabase(Adesk::kFalse, Adesk::kTrue );
}catch(...)
{
//put a breakpoint here to see of an exception is thrown
}

also try to change the parameters values of the constructor to see what
heapens

nick5454 wrote:
> so it creates the object. then before it finished with the constructor it calls delete for some reason and bombs.
>
> Please someone help
0 Likes
Message 10 of 11

Anonymous
Not applicable
There are many samples codes in ObjectARX SDK,
and you can learn a lot from it.
so before you post your Question, plz try yourself,

At last, i do not suggest you to using catch(...)
0 Likes
Message 11 of 11

Anonymous
Not applicable
You should check if you lock the current document before new a Database.
AutoCAD is developed based on COM model. Even if you use multiple
documents(databases), you still must lock doc except that ACAD has done for
you. acedCommand, and/or your own defined commands, etc. have locked doc
before executiving. And however, in some special cases, for example, while
using modelless dialog, you must explicitly lock it!

In fact, even if you dont delete db, the biggest problem is just memory
leaking, but not crash your app.

Lewis
www.hlsolution.com
HL Block Manager
HL CurveTool
HL STL Import/Export
************************************************************************

?AcDbDatabase* db = new AcDbDatabase(Adesk::kFalse, Adesk::kTrue );

is the only line of code. I amk trying to instantiate the Da6tabase object
toopen adrawing.



I get heap errors everytime.

Can anyone help

Nick
0 Likes