EagerSession.ResourceCleanupStrategy
Stay organized with collections
Save and categorize content based on your preferences.
Controls how TensorFlow resources are cleaned up when they are no longer needed.
All resources allocated during an EagerSession
are deleted when the session is
closed. To prevent out-of-memory errors, it is also strongly suggest to cleanup those resources
during the session. For example, executing n operations in a loop of m iterations will allocate
a minimum of n*m resources while in most cases, only resources of the last iteration are still
being used.
EagerSession
instances can be notified in different ways when TensorFlow objects are
no longer being referred, so they can proceed to the cleanup of any resources they owned.
Inherited Methods
From class
java.lang.Enum
final
int
|
compareTo(E arg0)
|
int
|
compareTo(Object arg0)
|
final
boolean
|
equals(Object arg0)
|
final
Class<E>
|
getDeclaringClass()
|
final
int
|
hashCode()
|
final
String
|
name()
|
final
int
|
ordinal()
|
String
|
toString()
|
static
<T extends Enum<T>>
T
|
valueOf(Class<T> arg0, String arg1)
|
From class
java.lang.Object
boolean
|
equals(Object arg0)
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
From interface
java.lang.Comparable
abstract
int
|
compareTo(E extends Enum<E> arg0)
|
Enum Values
public
static
final
EagerSession.ResourceCleanupStrategy
IN_BACKGROUND
Monitor and delete unused resources from a new thread running in background.
This is the most reliable approach to cleanup TensorFlow resources, at the cost of
starting and running an additional thread dedicated to this task. Each EagerSession
instance has its own thread, which is stopped only when the session is closed.
This strategy is used by default.
public
static
final
EagerSession.ResourceCleanupStrategy
ON_SAFE_POINTS
Monitor and delete unused resources from existing threads, before or after they complete
another task.
Unused resources are released when a call to the TensorFlow library reaches a safe point
for cleanup. This is done synchronously and might block for a short period of time the thread
who triggered that call.
This strategy should be used only if, for some reasons, no additional thread should be
allocated for cleanup. Otherwise, IN_BACKGROUND
should be preferred.
public
static
final
EagerSession.ResourceCleanupStrategy
ON_SESSION_CLOSE
Only delete resources when the session is closed.
All resources allocated during the session will remained in memory until the session is
explicitly closed (or via the traditional `try-with-resource` technique). No extra task for
resource cleanup will be attempted.
This strategy can lead up to out-of-memory errors and its usage is not recommended, unless
the scope of the session is limited to execute only a small amount of operations.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-04-21 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2020-04-21 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-04-21 UTC."],[],[]]