Re: Problem with memory leaks

From: Fabian Schmied (REMOVETHISfabianDOTschmied_at_fhs-hagenbergDOTacDOTat)
Date: 05/15/04


Date: Sat, 15 May 2004 13:39:25 +0200

Thomas schrieb:
> Now I managed to drop the memory-leaks to 5% (from 800 kb to 40kb) by
> calling the GC manually, everytime I use the device.
> But I don't think, that this is the right solution, because managed code
> should garbage-collect by its own.
> I write this here, because I think this could be helpful to solve the
> problem.

Okay, your application will be automatically garbage-collected when
memory is used up (or earlier, if your application is idling). This
means GC will eventually kick in and free all the memory (unless you are
holding references to dead objects). However, as a game developer, you
should try to make sure that GC isn't performed too frequently.
Certainly not once per device usage. Look at the memory allocations you
seem to be making on a per-frame basis. Are they really necessary? Could
you pool objects, i.e. create them once and reuse them whenever possible?

If you aren't sure where the allocations are being made, try to comment
out all of your code and gradually uncomment again, until it starts
eating memory again.

Fabian



Relevant Pages

  • Re: What is managed code?
    ... managed code is code that the runtime system handles all ... > aspects of memory and resource management. ... But since we know that resources on any given ... > also reference counted, which means that it is possible to create two ...
    (microsoft.public.vb.general.discussion)
  • Re: What is managed code?
    ... managed code is code that the runtime system handles all ... aspects of memory and resource management. ... But since we know that resources on any given system ... the Component Object Module runtime DLLs perform a simple reference ...
    (microsoft.public.vb.general.discussion)
  • [PATCH 2.6.28-rc5 01/11] kmemleak: Add the base support
    ... This patch adds the base support for the kernel memory leak ... overhead to memory allocations. ... +#ifdef CONFIG_DEBUG_MEMLEAK ... +static inline void memleak_free ...
    (Linux-Kernel)
  • Re: dataset Performence Issue
    ... Microsoft that a DataSet is okay to abuse as a DataBase. ... Managed Code can never be as fast and as optimized ... very good for 90% of the situations i.e. normal memory usage, ... Merge/GetChanges - and oh lets not forget keeping your disconnected cache ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: dataset Performence Issue
    ... of data to hold in memory in some applications. ... Network and disk costs see to that. ... First of all, Dataset is guess what - Managed Code, and to send all the ... You need paging mechanisms etc. which are ...
    (microsoft.public.dotnet.framework.adonet)