Skip to content

Commit e8aa765

Browse files
author
faiface
committed
add a note about memory leaks to Drawer and Sprite docs
1 parent bdbce3a commit e8aa765

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

drawer.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ package pixel
1515
//
1616
// Whenever you change the Triangles, call Dirty to notify Drawer that Triangles changed. You don't
1717
// need to notify Drawer about a change of the Picture.
18+
//
19+
// Note, that Drawer caches the results of MakePicture from Targets it's drawn to for each Picture
20+
// it's set to. What it means is that using a Drawer with an unbounded number of Pictures leads to a
21+
// memory leak, since Drawer caches them and never forgets. In such a situation, create a new Drawer
22+
// for each Picture.
1823
type Drawer struct {
1924
Triangles Triangles
2025
Picture Picture

sprite.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import "image/color"
1111
//
1212
// To achieve different anchoring, transformations and color masking, use SetMatrix and SetColorMask
1313
// methods.
14+
//
15+
// Note, that Sprite caches the results of MakePicture from Targets it's drawn to for each Picture
16+
// it's set to. What it means is that using a Sprite with an unbounded number of Pictures leads to a
17+
// memory leak, since Sprite caches them and never forgets. In such a situation, create a new Sprite
18+
// for each Picture.
1419
type Sprite struct {
1520
tri *TrianglesData
1621
frame Rect

0 commit comments

Comments
 (0)