Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Mar 2006 09:07:14 +0300
From:      Vasil Dimov <vd@FreeBSD.org>
To:        John Baldwin <jhb@freebsd.org>
Cc:        Robert Watson <rwatson@freebsd.org>, Jason Evans <jasone@freebsd.org>, freebsd-arch@freebsd.org
Subject:   Re: Proposed addition of malloc_size_np()
Message-ID:  <20060328060714.GB97222@qlovarnika.bg.datamax>
In-Reply-To: <200603271520.11381.jhb@freebsd.org>
References:  <44247DF1.8000002@FreeBSD.org> <200603271110.02917.jhb@freebsd.org> <44281421.3060401@FreeBSD.org> <200603271520.11381.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--GID0FwUMdk1T2AWN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Mar 27, 2006 at 03:20:08PM -0500, John Baldwin wrote:
> On Monday 27 March 2006 11:34, Jason Evans wrote:
[...]
> > 4) Porting code from Linux.  Case in point: Xara Xtreme, currently bein=
g=20
> > ported by Vasil Dimov.  At the moment, he has to use dlmalloc.
>=20
> Does it contain a G/C of its own or some such?
>=20

Here is what malloc_usable_size() is used for in Xara Xtreme:
* They keep track of how much (heap) memory is available. Maybe they
  support an option like "do not use more that N MiB". This is achieved
  by a wrappers to realloc() and free() which manipulate a global?
  variable AvailableRAM - the realloc() wrapper decreases AvailableRAM
  with (newsize - oldsize) where oldsize is retrieved with
  malloc_usable_size(). The free() wrapper increases AvailableRAM with
  what is returned by malloc_usable_size().
* Debugging purposes like keeping track of how much memory they
  allocated, the filename and linenumber of the allocation
* They use a function similar to realloc(), but which receives the
  number of bytes they need to increment the buffer with, rather than
  the new size, so they call realloc(p,increment+malloc_usable_size(p))
* A lot of other miscellaneous purposes where they should really keep
  track of how many bytes they requested from malloc() rather than
  calling malloc_usable_size().

--=20
Vasil Dimov
gro.DSBeerF@dv

Testing can show the presence of bugs, but not their absence.
                -- Edsger W. Dijkstra

--GID0FwUMdk1T2AWN
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----

iD8DBQFEKNKSFw6SP/bBpCARApOSAJ91DRTph0Jb5ynCUDFnT8Yx+e8gogCeNcuS
nQCPJsUyC/K/Mi6EbEkvyH0=
=VfHa
-----END PGP SIGNATURE-----

--GID0FwUMdk1T2AWN--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060328060714.GB97222>