CArchive and memory management problem

I am serializing a number of objects using CArchive.  While the archive is 
open, one group of objects is created off the heap, serialized and then 
deleted.  Later, a second group of objects does the same.  When conditions 
are right, the first object of the second group will get the same memory 
location off the heap as one of the objects from the first group.  When this 
happens, CArchive thinks it's trying to archive an object it already has.  It 
doesn't write the new object, but writes an offset to the object it thinks it 
has already (from the first group).  When reading the archive back, the 
object at the offset doesn't match the object requested and CArchive fires an 
exception.

Is there a way around this problem?  I need to allocate memory off the heap 
for both objects and can't do it until I'm ready to serialize each.

0
Moran (3)
8/25/2005 1:14:07 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
349 Views

Similar Articles

[PageSpeed] 31

"PT Moran" <PT Moran@discussions.microsoft.com> wrote in message 
news:29ADA722-8741-4B92-872A-F92D4210E5CC@microsoft.com...
>I am serializing a number of objects using CArchive.  While the archive is
> open, one group of objects is created off the heap, serialized and then
> deleted.  Later, a second group of objects does the same.  When conditions
> are right, the first object of the second group will get the same memory
> location off the heap as one of the objects from the first group.  When 
> this
> happens, CArchive thinks it's trying to archive an object it already has. 
> It
> doesn't write the new object, but writes an offset to the object it thinks 
> it
> has already (from the first group).  When reading the archive back, the
> object at the offset doesn't match the object requested and CArchive fires 
> an
> exception.
>
> Is there a way around this problem?  I need to allocate memory off the 
> heap
> for both objects and can't do it until I'm ready to serialize each.
>

Have you tried ZeroMemory after the memory allocation?  Are you sure this is 
the problem and not something your doing with the CArchive object?  How 
about some code snippets or a way to reproduce the problem?

-- 
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.


0
8/25/2005 2:18:31 PM

"Frank Hickman [MVP]" wrote:

> "PT Moran" <PT Moran@discussions.microsoft.com> wrote in message 
> news:29ADA722-8741-4B92-872A-F92D4210E5CC@microsoft.com...
> >I am serializing a number of objects using CArchive.  While the archive is
> > open, one group of objects is created off the heap, serialized and then
> > deleted.  Later, a second group of objects does the same.  When conditions
> > are right, the first object of the second group will get the same memory
> > location off the heap as one of the objects from the first group.  When 
> > this
> > happens, CArchive thinks it's trying to archive an object it already has. 
> > It
> > doesn't write the new object, but writes an offset to the object it thinks 
> > it
> > has already (from the first group).  When reading the archive back, the
> > object at the offset doesn't match the object requested and CArchive fires 
> > an
> > exception.
> >
> > Is there a way around this problem?  I need to allocate memory off the 
> > heap
> > for both objects and can't do it until I'm ready to serialize each.
> >
> 
> Have you tried ZeroMemory after the memory allocation?  Are you sure this is 
> the problem and not something your doing with the CArchive object?  How 
> about some code snippets or a way to reproduce the problem?
> 
> -- 
> ============
> Frank Hickman
> Microsoft MVP
> NobleSoft, Inc.
> ============
> Replace the _nosp@m_ with @ to reply.
> 
> 
> 

Thanks for your help.  Let me try to answer your questions.

I can look at the serialized file after the archive is done and see offsets 
written where I'd expect the actual objects.  I can also step through the 
CArchive code and see the writing of the offset instead of the actual object.

I then put in some debug statements to output the address of these objects 
when they are serialized.  I could see an address match between the first 
object of the first group and the first object of the second group.  This 
correleates with where an offset was written to the archive.

I don't think the data inside the object is causing this.  I'm not sure what 
code snippet to show.  We serialize a lot of objects and it's spread through 
many files.  There are only 2 object types that allocate memory, however, and 
I see this problem only if both types exist and are being serialized.

Regarding reproducing the problem.  I'm not familiar with windows memory 
management, so I don't know how to force memory to be allocated at a certain 
location, but if you could, you could reproduce the problem like this:

In the serialization routine of class 1:
- 'new' some objects at a forced memory location.
- serialize these objects
- free these objects

In the serialization routine of class 2:
- 'new' some objects at the same memory location as class 1.
- serialize these objects
- free these objects

Create a routine that serializes class 1 followed by serialization of class 2.

If you looked at the serialization file after running this, it should show 
offsets for those objects of class 2 that had the same memory location as 
those for class 1.

Do you know how to force a memory allocation to a specific location?  If you 
do, I could write a sample program to repeat this issue.

Again, thanks for your help,

Pat


0
PTMoran (1)
8/25/2005 3:09:08 PM
Reply:

Similar Artilces:

WAB and Office 2k3 problem
Greetings All: I've Outlook 2003 connected to an Exchange 2003 server. The only addresses that appear in my address book are the Global Addresses from the server, my contacts do not appear. Now when I go to the appropriate "Outlook Address Book" tab in the contacts properties dialog, the "Show this folder as an e-mail Address Book" checkbox is grayed out. I have several other contact folders that exhibit the same grayed out checkbox. If I try to add them from the Options dialog in the Address Book specifically, they don't even show up in the as being avail...

money 2006 problems importing from bank
whenever I import information from my bank uccu, it says that the import is complete and that I have one statement to read with 150 transactions to review, but when it opens to the account register, none of the new transactions show up. It shows the correct amount and date from my bank in the left hand corner, and it says that I still have 150 transactions to review. I have tried changing the online settings, emptying the temporary internet files, repairing the money file, and setting the account register to show all transactions, but so far nothing has worked. I have been able to i...

Money2004 (No MSN, no Passport) -> Monwy2006 Any problems?
I use M2004 without MSN, Passport or passwords. My financial institutions (Citi cards, Fidelity, Bank One) download into M2004 without any problems. Will I be able to transition into M2006 without any problems? I'll be happy to maintain the current M2004 features and capabilities. I'm thinking of M2006 only because the on-line stuff for M2004 will expire next year. -- Aloke ---- to reply by e-mail remove 123 and change invalid to com I imported without a problem but cannot now use MSN. I did not before and did not have a Passport. Adding the Passport works but synching with MS...

Where Does Outlook Store Info? Computer Problems
Recently the power supply, motherboard, & CPU on my computer died. So I had a new motherboard, power supply, CPU and hard drive installed. The new hard drive is larger and faster than the old one. This required that Windows XP, Microsoft Office, etc, had to be installed. But before any of that was done, the technician took everything off the old hard drive and saved it into a file on the new one. All of the old data files, etc, are supposed to be there. My question, though, is how to find the address book and the saved emails that were on the old computer & put them into Outlook on the...

Manager Assist ...... Field Service Module
Hi to all, I wnat to ask about Manager Assist, that is used to manage the calls on the service call module...... is it a GP module or it is a separate software thank you in advance, ManageAssist is a seperate VB application that connects to the GP Field Service tables. It allows for both viewing of schedule calls as well as updating of certain records (i.e. Unavailable time, sick time, etc.) -- Gary Neumann Field Service Series Designer/Architect "Eng. Tareq Sabri" wrote: > Hi to all, > > I wnat to ask about Manager Assist, that is used to manage the calls on th...

Update Download problem
I downloaded the latest update for Outlook 2000. I did NOT have the installation cd handy. Okay, usually no problem, the instal quits. However this time, it did quit, yet now I am unable to open excel. It launches the instal program. The download was for Outlook. It has me boggled. Outlook, Word and Access open with no known problems. I have tried to open excel different times/ways. It continues to try to load the update. Any reasoning on the subject??? Thanks* ...

Bank Recon GP 10 problem
Hi We are a VAR that's upgraded one client to GP 10 and installed GP 10 for another new client, both on SQL 2000. In both cases there's an incorrect balance showing for Cashbook Balance field (cashbook maintenance screen) using the Bank Recon module. Also the cashbook balance is not re-calculated (recon screen) when "Incl Trans To Date" field is changed, for both clients. We can update the balance in Cashbook Master table (CM00100) in SQL but this doesn't solve the problem. Any suggestions? ...

Protection Problem #3
I have a 3 sheet excel file with protection on all 3 sheets (let's call them A, B and C). These 3 pages have formulas that link to each other. Sheet A has a few checkboxes that link to sheet C. The problem is that when I try to check any of the check boxes on sheet A an error box pops up that says "The cell or chart you are trying to change is protected and therefore read only". Is there a way to protect a sheet while being able to check a box off that is linked to another sheet? What protection options would allow me to do this? Thanks in advance. Dave -- Dave123 ----------...

Connectivity Problems
Sorry about the length of this post, but I have no idea what I'm talking about, let alone explain it! We have two sites (Head Office and Remote) with a Netgear FVS338 VPN firewall at each end. The remote site connects via a Terminal Server and runs a couple of EPOS systems. Our setup in the Head Office is thus: Workstation -> SBS 2003 R2 Standard -> FVS338 VPN Firewall -> Internet Router Recently, the VPN keeps dropping and if I set up a permanent ping I can see that several times a day we get 7 or 8 pings timing out. This is enough to kill the EPOS connect...

The instruction at "0x77fc8fe3" referenced memory at "0x00746e69"
Does anyone know what this is from. It occurs at the end of the install when starting the crmsecurity service. Before the installation finishes the install crashes. Yes, I get the famous 80004005 error which I researched endlessly. Nevertheless, CRM is running into something on my system. Keith ...

problem with csv
When I export from a database I get the top line all in csv which appears to be in row A (which is the names of all the columns and the rest of the sheet is correct with all the data in relevant columns. How do I split that top row (which is Comma Separated) into coulumns automatically. I'm sure it is a simply process. thanks plato There is an easy way in Excel to split apart a cell without having to re-type its contents. Click on the cell. Pull-down Data > Text to Columns... > then check delimited and next check comma. The single cell should then split. Good Luck -- G...

Multiple problems with WLM
Multiple problems with WLM I realize that this problems list is long enough that it's unlikely that just one person will be able to solve them all. Therefore, it's OK to reply only for the one you can handle. Since some of these problems may be related, I decided to list them all in one post. 1. The All news view in the Quick views is either mislabelled, or unable to handle very large collections of unread newsgroups posts (I first saw this problem when the count was over 1,000,000, WLM was restarted, and the count dropped much lower (under 50,000). Since then I&#...

Moving Range Problem
Hi all, I'm trying to build a 6 Sigma control chart into an excel workbook. In order to do this i need to be able to work out a formula for the moving range. I need the following : Eg Data sample : 210 , 425 , 600 , 550 , 450 , 470 The moving range is the distance from second to the first, third to the second etc eg A B C D E F Data Sample 210 , 425 , 600 , 550 , 450 , 470 Moving Range 215, 175 , 50 , 100 , 20 The problem I'm having is trying to get excel to work it out. If say 210 was in A1 i ...

Timesheet Problem #2
I am trying to populate a timesheet with dates depending on the start date in B2. If B2 is the 16th of the month of Sept, I don't want anything to show up on the calendar for the 31th (blank in other words). Here is the formula I am using, but not working. Help. TIA =IF(($B$2)="","31",IF(EOMONTH(B2,0)=TEXT(($B$2)+ROW()-14,"DDD dd"),"",TEXT(($B$2)+ROW()-14,"DDD dd"))) Greg Hi Greg, With seed date in cell $B$2 and using rows down to leave the 31st blank. But show all other dates no exceptions for weekends and holidays. EOMONTH is in ...

Task Manager
My work is based on projects that are email oriented. A specific project is rec'd, forwarded, replied to until it is complete and that email is closed. I am trying to use Task Manager to help organize these emails. I transfer an email to Task Manager by dragging it to the TM icon so that it saves it with the text in place but when I try to forward my response to someone else thru TM, it always forwards as an attachment. I know there is a way to forward these emails so that they show up in someone else's Inbox with the text displayed but I can't figure out how to do it! I ...

Pivot Table Refresh error "Problems Obtaining Data"
I can't seem to get data or change the data source. When I refresh, I get the error message "Problems Obtaining Data" When I start the Pivot Table Wizard, the back button is grayed out so that I can't go back and change data sources. Any help is appreciated. ...

Admin Problem from 5.5 to 2k3 Exchange
We just migrated all of our email boxes to Exchange 2k3 from Exchange 5.5. Now our administrators can't look at any of the users outlook information unless they are given the rights from that users. Before the administrators could look at the persons information and remove or help the people with problems and questions if need be. How can our Administrators gain access to these exchange boxes again? There are several articles out there on this. In E2K3, domain admins and enterprise admins are explicitly denied this access. There are work arounds. try this: http://www.winnetma...

XML DATASET problem
I am having big problem manipulating XML in a dataset. I am reading in a schema based on the following XML document. The minute I try to e.g. create a new row I get 'Object reference not set to an instance of an object' error <?xml version="1.0" encoding="utf-8"?> <DocumentElement xmlns="http://tempuri.org/dseditted2.xsd"> <TableInfo> <FieldName>column value</FieldName> <ControlType>column value</ControlType> <IsNull>column value</IsNull> <MaxLength>column value</MaxLength> </TableInfo&g...

Problem with external data and #reference error
Hi, my Excel workbook has 2 sheets: 1. Source: with an external data reference to a MS Access database Query property "If number of rows changes after refresh" is set to option #1: "Insert cells for new data, delete unused cells" User chooses external query selection criteria and therefore can have different result sets. 2. Target: Formular B4: =Source!P5 Formular B5: =Source!P6 Formular B6: =Source!P7 Problem: When Source has data in rows 5, 6 and 7 formular gets calculated correctly. If Source row #5 has data and #6 and ...

Problem with copying and pasting tasks and keeping predecessors in
I am doing a consulting project for an organization that has a bit of an unusual request. We are doing a conversion from an old mail system to Microsoft Exchange 2007. We have developed a checklist for the technicians to follow with about 50 detailed tasks (things like, "Open up Exchange Management Console", "Assure the 'Forward' Button is unchecked", etc.). The CIO expects me to enter each of the tasks from the checklist into the project plan. Instead of having a line on the project plan with a task, "Covert Leroy Smith's Mailbox" wi...

Charting Problem #2
I have a problem with charting a Dynamic chart. I goes ok to set up the dynamic function as a range. It also shows the correct series. The range is as follows: =OFFSET(Sheet3!$A$1;1;Sheet3!$P$2-1;COUNTA(INDIRECT("C"&Sheet3!$P$2;FALSE));1) Where P2 is an input from a listbox, and the name of the range is: Sheet3!Dato. When I try to change the reference for the series i get the following message: "Your formula contains an invalid external reference to a worksheet. Verify the path, workbook, and range name or cell reference are correct, and try again." The serie...

GP2010
What are the options for a Requisition Management solution for new GP BRL Adv Mgmt customers? It is my understanding that the Req Mgmt module has been taken off the GP BRL AM price list. Thanks, John ...

XmlDataDocument problem
Hi, I have a problem reading xml into a dataset using the XmlDataDocument. In a test project, I created the following xml file: <?xml version="1.0" standalone="yes"?> <Customer> <OrderDetails> <OrderID>5</OrderID> <ProductID>6</ProductID> </OrderDetails> </Customer> And I use the following code to read it: TestDataSet ds = new TestDataSet(); // TestDataSet is a typed dataset with 1 table "OrderDetails", with 1 column "OrderID" System.Xml.XmlDataDocument doc = new System.Xml.XmlDataDocument(d...

Outlook Calendar views problem
Hey all... going to describe this to the best of my ability... but its one of those 'a picture would be worth a 1000 words' deals. Outlook Calendar views. We have a calendar shared among our entire company. In that Calendar we wish to create a timeline view availbale to anyone with permissions to view the calendar. We have created this view called 'timeline' and it appears that it is available to users of that folder. Sort of. Its there, but in teh outlook calendar / shared calendar / views pane, the view will ONLY show up when the calendars are in a timeline state as oppose...

Problems with Lead/Contact sharing?
Has anyone else had problems with Leads/Contact sharing themselves between users for no reason? We're having some issues where our leads/contacts are randomly being shared between SCs and TSCs. Doesn't make any sense at all... We had the same problem with Opportunities being shared without anyone actually sharing them. We poked around at it a bit and discovered that when a record is Assigned to another sales person, the person doing the assigning is automatically setup with sharing on that record. Our problem is that we can't seem to figure out how to get rid of the sharin...