generated from cloudwego/.github
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update README.md * fix: invalid frame pointer] * Update README.md
- Loading branch information
Showing
6 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package creator | ||
|
||
type InnerMessage struct { | ||
msgs []string | ||
} | ||
|
||
type MyChan struct { | ||
cchan chan *InnerMessage | ||
} | ||
|
||
type SubRequest struct { | ||
E map[string]string | ||
F map[int64]*MyChan | ||
} | ||
|
||
type Request struct { | ||
A *int64 | ||
B *string | ||
C []string | ||
D *SubRequest | ||
X []*SubRequest | ||
} | ||
|
||
func Create() interface{} { | ||
buf := make([]byte, 1024) | ||
str := string(buf) | ||
return &Request{ | ||
A: new(int64), | ||
B: &str, | ||
C: []string{string(buf), string(buf), string(buf)}, | ||
D: &SubRequest{ | ||
E: map[string]string{ | ||
string(buf): string(buf), | ||
}, | ||
F: map[int64]*MyChan{ | ||
123456: { | ||
cchan: make(chan *InnerMessage, 100), | ||
}, | ||
}, | ||
}, | ||
X: []*SubRequest{ | ||
{ | ||
E: map[string]string{ | ||
string(buf): string(buf), | ||
}, | ||
F: map[int64]*MyChan{ | ||
123456: { | ||
cchan: make(chan *InnerMessage, 100), | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package holder | ||
|
||
func ReceiveChan() chan interface{} { | ||
ch := make(chan interface{}, 100) | ||
go func() { | ||
var cached []interface{} | ||
for v := range ch { | ||
cached = append(cached, v) | ||
} | ||
}() | ||
return ch | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"net/http" | ||
_ "net/http/pprof" | ||
"time" | ||
|
||
"github.com/cloudwego/goref/testdata/mockleak/creator" | ||
"github.com/cloudwego/goref/testdata/mockleak/holder" | ||
) | ||
|
||
func main() { | ||
go func() { | ||
log.Println(http.ListenAndServe("localhost:6060", nil)) | ||
}() | ||
receiver := holder.ReceiveChan() | ||
for i := 0; i < 100000; i++ { | ||
receiver <- creator.Create() | ||
} | ||
time.Sleep(1 * time.Minute) | ||
} |