Re: Memory leak

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Sherif ElMetainy (elmeteny.NOSPAM_at_wayout.net.NOSPAM)
Date: 01/09/05


Date: Sun, 9 Jan 2005 19:54:36 +0200

Hello

You are right, but in your test you are allocating a lot of large arrays
which goes to the the large object heap. Allocating a lot of large objects
causes a lot of generation 2 collections which hurts perfomance badly.
Typically you should design your application so that large objects
allocation are not frequent and when they do happen the large objects should
not be short lived.

Best regards,
Sherif
> Hi,
>
> my story, last year, I did a memory-stress-test by simply creating a
> bunch of small objects (8 bytes in size, that is, an integer and the
> implicit vmt pointer) and storing them in an array (500000 elements).
> When the array is full, a new array is created and populated and so on
> and so on. This went well, up until a certain memory load. Further
> allocating, beyond this point, began taking more and more time. You
> could also notice lots of harddisk activity, which must be swap activity.
> My conclusion: everything goes well, when there's enough free physical
> memory. No (or less) swapping is needed, the garbage collector does not
> run much often and allocation is pretty fast. But when free memory gets
> very rare (the OS already is swapping things back and forth) the GC is
> run more often. When the GC runs, it scans whatever it thinks is
> necessary, causing even more page faults, causing the application to
> choke. This does not happen in applications without a garbage collector
> (pretty much every application before the .net/java/... period). With
> 'native' applications, pages that are swapped out of memory stay on disk
> until the application references them. There's no garbage collector
> that needs to scan (read: reload from swapfile) the *entire* memory
> space for unreferenced objects.
> So, your application scales with the amount of free physical memory.
> (IMHO)
>
> Cheers,
> Benoit.
>



Relevant Pages

  • Re: J4 - presentation/discussion on "Future of the COBOL Standard"
    ... there is obviously no problem with allocating the maximum ... array size: all that's actually needed in the compiled program is a ... gigantic physical memory spaces are no longer news. ... compilers that actually allocate space as part of the compiled unit will ...
    (comp.lang.cobol)
  • Re: Difference?
    ... > allocating memory for an array of objects. ... > that malloc will align the memory assuming that the memory allocated ...
    (comp.lang.c)
  • Re: Why delete [] for aray?
    ... Does he use of delete instead of deletewill cause a memory leak? ... the pointer points to an array. ... Moreover, when allocating arrays of classes with non-trivial destructor, ...
    (microsoft.public.vc.language)
  • Re: Fast Linear Hex Search
    ... I've had this happen many times and someone on the Perl ... Perl allocates memory but does not free up memory as quickly ... > simply because Perl's garbage collector hasn't realized that some of the ... > you can make the original array global versus local. ...
    (comp.lang.perl.moderated)
  • Re: Limits to memory allocated in DLL
    ... >inside a DLL? ... >I am creating the following array inside a dll: ... allocating this memory in the DLL, ...
    (microsoft.public.vc.mfc)