shalskar / PeekAndPop

497 stars 65 forks source link

Hold and Release view outOfMemoryexception. #21

Open anukools opened 7 years ago

anukools commented 7 years ago

Hey, I got several outOfMemoryExcetion in HoldAndReleaseView. Here are the logs.

Fatal Exception: java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again at java.lang.Thread.nativeCreate(Thread.java) at java.lang.Thread.start(Thread.java:1063) at java.util.Timer$TimerImpl.(Timer.java:192) at java.util.Timer.(Timer.java:365) at java.util.Timer.(Timer.java:384) at java.util.Timer.(Timer.java:391) at peekandpop.model.HoldAndReleaseView.(SourceFile:25) at .peekandpop.PeekAndPop.addHoldAndReleaseView(SourceFile:501).

hjudez commented 7 years ago

Same here. Any solution to this? Seems a new thread is created inside Timer every time we call addLongClickView

hjudez commented 7 years ago

Basically don't create a new Timer in the constructor as it is then created for every time my adapter calls onBindViewHolder. And check if it is not null in cancelPendingTimer.

public PeekAndPopOnTouchListener(int position) { this.position = position; longHoldTimer = new Timer(); }