Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/1063#discussion_r82057266
  
    --- Diff: proxy/Main.cc ---
    @@ -346,6 +346,54 @@ class DiagsLogContinuation : public Continuation
       }
     };
     
    +class MemoryLimit : public Continuation
    +{
    +public:
    +  MemoryLimit() : Continuation(new_ProxyMutex()), _memory_limit(0) { 
SET_HANDLER(&MemoryLimit::periodic); }
    +  ~MemoryLimit() { mutex = NULL; }
    +  int
    +  periodic(int event, Event *e)
    +  {
    +    if (event == EVENT_IMMEDIATE) {
    +      // rescheduled from periodic to immediate event
    +      // this is the indication to terminate
    +      delete this;
    +      return EVENT_DONE;
    +    }
    +    if (_memory_limit == 0) {
    +      // first time it has been run
    +      _memory_limit = 
REC_ConfigReadInteger("proxy.config.memory.max_usage");
    +    }
    +    if (_memory_limit > 0) {
    +      if (getrusage(RUSAGE_SELF, &_usage) == 0) {
    +        Debug("server", "memory usage - ru_maxrss: %ld memory limit: %" 
PRId64, _usage.ru_maxrss, _memory_limit);
    +        if (_usage.ru_maxrss > _memory_limit) {
    --- End diff --
    
    What units are we working with here? ``ru_maxrss`` is in KB, but one would 
think that ``proxy.config.memory.max_usage`` is in bytes? 
``proxy.config.memory.max_usage`` as bytes makes sense because then you can do 
``proxy.config.memory.max_usage=100GB``.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to