How to reclaim space in Structured Storage

How to reclaim space in Structured Storage

Post by Alexander Nickolo » Sat, 05 Oct 2002 04:52:56



This behavior is by design (or rather implementation). If you want
to compact your compound file, create a new one and make a copy
of the root storage into it. There must be something to this effect
mentioned in the documentation I'm sure...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


> When I delete Streams in the Structured Storage file (by calling the
> DestroyElement function in the IStorage), the space occupied by the stream
> is not reclaimed.  I am not using Transactions.  The stream is deleted and I
> can't get to it.  But the size of the whole file remains the same.  I tested
> this by adding and deleting huge streams (>50MB) so I can see the change in
> the storage file size.  I also tried copying the storage file into a
> different folder to see that would shrink the file.  But it did not help.
> Please let me know if there is an API or a method to reclaim teh space.

> Thanks
> SP

 
 
 

1. A novel technique for reclaiming space after program startup.

In many programs, a number of functions exist only for the purpose of
getting various data structures initialized properly upon program startup.
Following these initializations, such functions are essentially useless,
and the space they occupy in memory is essentially wasted.  (Of course on
systems that support paged virtual memory, this is a non-issue, but on
other systems, such as MS-DOS, the waste of space may be troublesome.)

I have just noticed an interesting way to help reduce this problem.  It
is illustrated by the following code:

        typedef void (FT) ();

        void gets_destroyed () { /* ... */ }

        FT *fp = gets_destroyed;

        void
        delete_init_functions ()
        {
                fp->~FT ();  /* destruct the function */
        }

Once the initialization functions have been properly destroyed (as illustrated
above) the space they formerly occupied may be reclaimed and used for data
storage.

Warning:  Due to bugs in some implementations, this technique is currently
not completely portable, and the code shown above may not be accepted by
all implementations... but many/most/all cfront-based implementations
should accept it.

:-) :-) :-)

--

-- Ronald F. Guilmette ------------------------------------------------------

------ uucp address: ...!uunet!netcom.com!rfg -------------------------------

2. FS: Epson LX86 dot matrix printer

3. short on portable storage space???

4. ***** FRE INTERNET ****

5. LOGINOUT BUG WHICH CAUSES LOOPING WHEN DOING A SET HOST.

6. storage space comparison (was Re: Unreal 2: Thumbs up)

7. CD Explorer question

8. IStream / Structured Storage

9. A whole file in Structured Storage?

10. Q 4 Gurus and Internists (Structured Storage)

11. OLE Structured storage...summary information