<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Thank you for the answer,<br><br>That explains why loading a bitmap (without the shadow byte-string)<br>didn't raise the the value reported by current-memory-use.<br><br>I'm wondering now in what way this helps the GC and the memory-limit checks?<br>The reason I started looking into this was that DrRacket kept running out of memory<br>and closing down without a warning (even with a memory limit set to 512 MB).<br>So to me it seems that for current-memory-use and DrRacket's memory limit check<br>this trick doesn't really work. But maybe this is not the intended purpose of the<br>shadow byte-string.<br><br>Bert<br><br><br><div><div id="SkyDrivePlaceholder"></div>> From: mflatt@cs.utah.edu<br>> To: bedeke@hotmail.com<br>> CC: users@racket-lang.org<br>> Subject: Re: [racket] bitmap% size in memory<br>> Date: Wed, 19 Dec 2012 07:11:24 -0700<br>> <br>> The "shadow" byte string is indeed unused. It's there only as an<br>> accounting trick for Racket's garbage collector.<br>> <br>> The memory used for the actual bitmap is not visible to the garbage<br>> collector, so it doesn't directly count towards a program's (or<br>> custodian's) memory use. The shadow byte string is allocated and kept<br>> alive during the same time as an actual bitmap to create GC-visible<br>> memory use. That is, the shadow byte string triggers full garbage<br>> collections and memory-limit checks as needed to keep the system as a<br>> whole working right.<br>> <br>> This trick does use about twice the memory that a bitmap would<br>> otherwise use, but it makes the garbage collector and bitmaps play<br>> nicely without complex changes to the garbage collector.<br>> <br>> At Wed, 19 Dec 2012 08:10:37 +0100, Bert De Ketelaere wrote:<br>> > <br>> > Hello all,<br>> > <br>> > When loading large pictures (± 4300x2600 pixels) I would expect that they takes <br>> > up around 45Mb of memory.<br>> > But when I monitored my program in windows task-manager I noticed it was more <br>> > in the neighborhood of 100Mb (after garbage collection, the in-between values <br>> > goes over 200Mb)<br>> > Hoping to find a reason for this I went looking into racket/draw/bitmap and <br>> > noticed that there is a variable "shadow" that is set to a zeroed out <br>> > byte-string, the size of the picture. But the only thing happening with this <br>> > "shadow" is it's definition and a set!. It is never read.<br>> > I tried removing the two references to "shadow", and in my programs everythings <br>> > seems to keep working, with the added bonus that the picture now indeed takes <br>> > only around 45Mb instead of 100Mb.<br>> > <br>> > two questions:<br>> > As far as I understand classes, since shadow is locally defined, no parent or <br>> > child can access shadow, so removing it should be ok. Is this right?<br>> > Is there a way to see how much memory an object occupies?<br>> > <br>> > Bert<br>> > <br>> >                                            ____________________<br>> > Racket Users list:<br>> > http://lists.racket-lang.org/users<br></div>                                            </div></body>
</html>