Home  >  Q&A  >  body text

java - 当消息生产者生产消息的能力远远大于消息的消费者的消费能力时,该如何解决内存泄漏的问题?

当消息生产者生产消息的能力远远大于消息的消费者的消费能力时,程序会发生什么事?

例如我这里有组桥接的生产者,每30秒会发布3700万条消息,而消费者就是一个简单的客户端,处理这3700万条消息,消费者会发生什么事?

//我知道消费者的缓冲队列会爆满溢出,导致内存泄露

怎么解决?

PHP中文网PHP中文网2741 days ago590

reply all(3)I'll reply

  • 高洛峰

    高洛峰2017-04-18 10:32:07

    • First of all, this is not called a memory leak. The name is a bit loose

    • If you don’t have high reliability requirements, you can consider randomly throwing away some

    • Expansion Hardware

    • If you have requirements for reliability. To put it simply, it is thrown into the hard disk or database first. In short, it cannot be stored in the memory. It's a bit like the Socket instance in Java. There is an InputStream and OutputStream that maintain a SendQ queue and a RecvQ queue respectively, but it is in memory and we just put it on the hard disk.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-18 10:32:07

    Isn’t there one RejectedExecutionHandler?

    reply
    0
  • 黄舟

    黄舟2017-04-18 10:32:07

    Even if the memory is leaked, the computer still doesn’t crash. RejectedExecutionHandler handles rejected tasks, why not use redis, haha

    reply
    0
  • Cancelreply