Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: Memory leak when we cannot access remote url #41422

Closed
omarsy opened this issue Sep 16, 2020 · 2 comments
Closed

net/http: Memory leak when we cannot access remote url #41422

omarsy opened this issue Sep 16, 2020 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@omarsy
Copy link

omarsy commented Sep 16, 2020

What version of Go are you using (go version)?

$ go version
1.13

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

Windows

go env

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\SESA571965\AppData\Local\go-build
set GOENV=C:\Users\SESA571965\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\SESA571965\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\SESA571965\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\SESA571965\Documents\EdgeCore.omar\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\SESA57~1\AppData\Local\Temp\go-build800121138=/tmp/go-build -gno-record-gcc-switches


$ go env

What did you do?

When I run this code with a non-existent url. I have memory leak

package main

import (
	"crypto/tls"

	"net/http"
	"net/url"
	"strings"
)

func main() {
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}
	client := &http.Client{Transport: tr}
	for true {
		login(client)
	}
}

func login(client *http.Client) error {
	loginURL, err := url.Parse("https://notAccessibleAdress")
	if err != nil {
		return err
	}
	form := url.Values{}
	form.Add("grant_type", "password")
	form.Add("username", "c.username")
	form.Add("password", "c.password")
	r, err := http.NewRequest("POST", loginURL.String(), strings.NewReader(form.Encode()))
	if err != nil {
		return err
	}
	r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	resp, err := client.Do(r)
	if resp != nil {
		defer resp.Body.Close()
	}
	defer client.CloseIdleConnections()
	return err
}

What did you expect to see?

What did you see instead?

@omarsy omarsy changed the title net/http: Memory leak when we cannot access to the remote url net/http: Memory leak when we cannot access remote url Sep 16, 2020
@davecheney
Copy link
Contributor

Can you please describe how you have determined you have a memory leak so someone can attempt to reproduce what you see.

Which tools did you use, how did you run them, what output did you see, and how did you determine that this was a leak?

@toothrot toothrot added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Sep 16, 2020
@toothrot toothrot added this to the Backlog milestone Sep 16, 2020
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Oct 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants