Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Koral
gcmh
Commits
f542908b
Commit
f542908b
authored
Aug 07, 2019
by
Koral
Browse files
Merge branch 'feature/prevent-duplicate-timers' into 'master'
Feature/prevent duplicate timers See merge request
!2
parents
1953d913
537d050e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
gcmh.el
gcmh.el
+11
-8
No files found.
gcmh.el
View file @
f542908b
...
...
@@ -35,16 +35,16 @@
;;; Code:
(
defcustom
gcmh-low-cons-threshold
800000
"Low cons
gc
threshold.
This is the
gc
threshold used while
while
idling. Default value
is the
same of `gc-cons-threshold' default"
"Low cons
GC
threshold.
This is the
GC
threshold used while idling. Default value
is the
same of `gc-cons-threshold' default
.
"
:group
'gcmh
:type
'number
)
(
defcustom
gcmh-high-cons-threshold
#x40000000
"High cons
gc
threshold.
"High cons
GC
threshold.
This should be set to a value that makes GC unlikely but does not
make th
e OS paging."
caus
e OS paging."
:group
'gcmh
:type
'number
)
...
...
@@ -59,7 +59,7 @@ make the OS paging."
:type
'boolean
)
(
defvar
gcmh-idle-timer
nil
"Idle timer for trigering GC."
)
"Idle timer for trig
g
ering GC."
)
(
defmacro
gcmh-time
(
&rest
body
)
"Measure and return the time it takes to evaluate BODY."
...
...
@@ -68,7 +68,7 @@ make the OS paging."
(
float-time
(
time-since
time
))))
(
defun
gcmh-set-high-threshold
()
"Set the high
gc
th
e
reshold.
"Set the high
GC
threshold.
This is to be used with the `pre-command-hook'."
(
setq
gc-cons-threshold
gcmh-high-cons-threshold
))
...
...
@@ -86,6 +86,10 @@ This is to be used with the `pre-command-hook'."
"Minor mode to tweak Garbage Collection strategy."
:lighter
" GCMH"
:global
t
;; Cancel any pending timer (prevents duplicate idle timers).
(
when
(
timerp
gcmh-idle-timer
)
(
cancel-timer
gcmh-idle-timer
))
(
if
gcmh-mode
(
progn
(
setq
gc-cons-threshold
gcmh-high-cons-threshold
...
...
@@ -94,7 +98,6 @@ This is to be used with the `pre-command-hook'."
#'
gcmh-idle-garbage-collect
))
;; Release severe GC strategy before the user restart to working
(
add-hook
'pre-command-hook
#'
gcmh-set-high-threshold
))
(
cancel-timer
gcmh-idle-timer
)
(
setq
gc-cons-threshold
gcmh-low-cons-threshold
gcmh-idle-timer
nil
)
(
remove-hook
'pre-command-hook
#'
gcmh-set-high-threshold
)))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment