473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Strange problem with new in a DLL

I created a DLL that reads a pointer to a vector created in a
console-mode test app as:
vector<LineItem*>* pLineItems = new vector<LineItem*>;
Everything seems to work fine (except for memory leaks) if I don't do
a delete in the test app. But if I do, I get an exception on the test
app's return 0 statement.

BoundsChecker tells me that I am attempting to free memory in the DLL
that was allocated in the test routine. I don't understand this
because the DLL does not contain even a single delete.

Can someone shed some light on this behavior? Thanks ... Al
Jul 19 '05 #1
2 1585
"Al Newton" <al*******@hotmail.com> wrote...
I created a DLL that reads a pointer to a vector created in a
console-mode test app as:
vector<LineItem*>* pLineItems = new vector<LineItem*>;
Everything seems to work fine (except for memory leaks) if I don't do
a delete in the test app. But if I do, I get an exception on the test
app's return 0 statement.

BoundsChecker tells me that I am attempting to free memory in the DLL
that was allocated in the test routine. I don't understand this
because the DLL does not contain even a single delete.

Can someone shed some light on this behavior? Thanks ... Al


You probably need to ask in a newsgroup where DLLs are on topic.
As far as C++ is concerned, if you allocate memory in a program,
you should be able to free it in the same program.

<offtopic> You might want to make sure that both the App and the
DLL use the run-time library as a DLL too</offtopic>

Victor
Jul 19 '05 #2
Al Newton wrote:
I created a DLL that reads a pointer to a vector created in a
console-mode test app as:
vector<LineItem*>* pLineItems = new vector<LineItem*>;
Everything seems to work fine (except for memory leaks) if I don't do
a delete in the test app. But if I do, I get an exception on the test
app's return 0 statement.

BoundsChecker tells me that I am attempting to free memory in the DLL
that was allocated in the test routine. I don't understand this
because the DLL does not contain even a single delete.

Can someone shed some light on this behavior? Thanks ... Al


I don't know how bounds checker works but it's likely that it is not
reporting correctly.

The problem is that the new() operator is inlined and bounds checker
probably only knows about malloc and free. Hence what bounds checker is
reporting is totally bogus.

How to fix this in win32 apps is still a mystery to me, however with gcc
there are ways to make it so that checkers can work correctly.
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Arthur | last post by:
I've come across some strange xml, that I need to deal with, it looks like this:- <root> <foo attr="1">Some random strange text. <bar attr="2">blar</bar> <bar attr="3">blar blar</bar> <bar...
2
by: Olaf | last post by:
I have a frameset page witch contains the myFuc() function. The function is accessed from a page in one of the frames in the frameset. An example is shown below. <input...
7
by: M O J O | last post by:
Hi, I'm developing a asp.net application and ran into a strange css problem. I want all my links to have a dashed underline and when they are hovered, it must change to a solid line. Sounds...
25
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's...
0
by: unknown | last post by:
Hi, I am developing an online book store with shopping cart. My shopping cart is represented as a Xml server control and I am using an XSLT to render it at the client side. I am using an...
0
by: Kris Vanherck | last post by:
yesterday i started getting this strange error when i try to run my asp.net project: Compiler Error Message: CS0006: Metadata file 'c:\winnt\microsoft.net\framework\v1.1.4322\temporary asp.net...
6
by: Gary | last post by:
I have an application that has been working just fine for a couple of years. It queries a SQL database and returns some formatted data back to the client. I have a new client, who has a larger...
11
by: Martin Joergensen | last post by:
Hi, I've encountered a really, *really*, REALLY strange error :-) I have a for-loop and after 8 runs I get strange results...... I mean: A really strange result.... I'm calculating...
20
by: SpreadTooThin | last post by:
I have a list and I need to do a custom sort on it... for example: a = #Although not necessarily in order def cmp(i,j): #to be defined in this thread. a.sort(cmp) print a
14
by: blumen | last post by:
Hi all, I'm a newbie in VB.Net Programming.. Hope that some of you can help me to solve this.. I'm working out to read,parse and save textfile into SQL Server. The textfile contains thousands...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.