overcoming a dealocating memory problem ?
From: Jole (no_spam_at_nospam.com)
Date: 05/12/04
- Next message: Tony Morris: "Re: How to use a system call to find the name of my Java class"
- Previous message: Yu Song: "Re: network effeciently"
- Next in thread: Gordon Beaton: "Re: overcoming a dealocating memory problem ?"
- Reply: Gordon Beaton: "Re: overcoming a dealocating memory problem ?"
- Reply: Michael Borgwardt: "Re: overcoming a dealocating memory problem ?"
- Reply: Tony Morris: "Re: overcoming a dealocating memory problem ?"
- Reply: Jole: "Re: overcoming a dealocating memory problem ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 12 May 2004 08:48:21 GMT
Hi
I'm using serialization to read in an object from a file. My code basically
does this:
1)MyClass obj = (MyClass) in.readObject();
('in' is an ObjectInputStream wrapped around a FileInputStream object, ie
the code reads an object stored in a file on disk)
Now, what happens is my code does this once at the start (works fine), but
later i need to do the same thing, to read in an updated version of the
object. ie, i need to do this again:
2) obj = (MyClass) in.readObject();
the compiler tells me that obj is constant and can't be assigned again. I
was hoping i could do something like this at step 2:
delete obj; //free memory
obj = (MyClass) in.readObject(); //read in new version of object from file
//and assign it to the same reference
(don't pay attention to the syntax, but the concepts..ie the above frees the
associated memory and then reads in a new copy from the file and assigns it
to the reference obj)
There doesn't seem to be a way to do it. Any ideas?
thanks
Jole
- Next message: Tony Morris: "Re: How to use a system call to find the name of my Java class"
- Previous message: Yu Song: "Re: network effeciently"
- Next in thread: Gordon Beaton: "Re: overcoming a dealocating memory problem ?"
- Reply: Gordon Beaton: "Re: overcoming a dealocating memory problem ?"
- Reply: Michael Borgwardt: "Re: overcoming a dealocating memory problem ?"
- Reply: Tony Morris: "Re: overcoming a dealocating memory problem ?"
- Reply: Jole: "Re: overcoming a dealocating memory problem ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|