Memory leak found on 1.4.4
See original GitHub issueI found a memory leak problem on version 1.4.4 You can use the segment code below in order to reproduce easily.
Maybe you need install lib psutil
- it helps collecting memory info
def create_kafka_producer(**kwargs):
bootstrap_servers = kwargs.pop(
'bootstrap_servers', None) or os.environ.get('KAFKA_SERVER')
assert bootstrap_servers is not None, 'bootstrap_servers should not be none'
producer = KafkaProducer(
bootstrap_servers=bootstrap_servers,
client_id="test_leak_memory",
retries=2,
batch_size=200 * 1024,
max_request_size=3 * 1024 * 1024
)
return producer
topic = 'test_mem_leak'
dummy = {
'parcel_id': time.time(),
'chosen_carrier': "{}_{}".format(randint(0, 10), randint(0, 5)),
'event_count': 1,
'imported_date': '',
'should_send_kick_off_msg': False,
'scraping_parameters': {}
}
dummy_str = json.dumps(dummy)
dummy_byte = str(dummy_str).encode()
producer = create_kafka_producer()
def on_send_success_cb(msg, record_metadata):
print("msg={}".format(msg))
def produce_msg(limit=2000):
for _ in range(limit):
producer.send(topic, value=dummy_byte).add_callback(functools.partial(on_send_success, dummy))
producer.flush()
def produce_msg_without_leak_mem(limit=2000):
""""if you pass function and its params to future.add_callback directly, it's ok. Although I found another partial is created inside"""
for _ in range(limit):
producer.send(topic, value=dummy_byte).add_callback(on_send_success, dummy)
producer.flush()
if __name__ == '__main__':
monitor_logger.info("Start test_leak_memory at {}".format(datetime.now()))
start_rss = psutil.Process(os.getpid()).memory_info().rss
for _ in range(10):
produce_msg(limit=2000)
time.sleep(5)
end_rss = psutil.Process(os.getpid()).memory_info().rss
gc.collect()
gc_rss = psutil.Process(os.getpid()).memory_info().rss
monitor_logger.info("Produce success {} msgs".format(max_offset - min_offset))
monitor_logger.info("Total consumed memory: {} KB".format((end_rss - start_rss) / 1024.0))
monitor_logger.info("After gc.collect - Total consumed memory: {} KB".format((gc_rss - start_rss) / 1024.0))
Call produce_msg
several times, we got memory increases overtime.
But take a look produce_msg_without_leak_mem
method, if you pass function and its params to future.add_callback
directly, it’s ok. Although I found another partial
is created inside.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10
Top Results From Across the Web
Windows 10 Memory Leaks (ProC (2.3G), ConT (1.4G)
Windows 10 Memory Leaks (ProC (2.3G), ConT (1.4G), PIDs above 200,000). Hello Microsoft Community,. ---. OS: Windows 10 Professional x64.
Read more >Memory leak or to be expected - Stack Overflow
In this tool I found that there are loads of classes being loaded the first 2 minutes of the game. And 5 a...
Read more >[SOLVED] Memory leak - how can I locate it?
The report tells you that the memory leaks are created in the procedure TForm1.Button1Click, line 48 of unit1.pas. Then uncomment the "L.Free" ...
Read more >Memory leaks in OSweb 1.4 (sketchpad/feedback/sampler)
Hi there, While running an experiment with OSWeb 1.4, several participants reported the task crashing or sound stimuli getting distorted or ...
Read more >PowerVC: Openvswitch memory leak may cause SDN ... - IBM
IBM PowerVC SDN running PowerVC 1.4.4 and prior. Diagnosing The Problem. Collect a novalink pedbg. pedbg -c -q 4. Ask support to review ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for your support, I closed this issue now, will reopen as I collect more proper information that helps reproduce easier
No change after a few hours even with prints in the handler. Not sure if I can help any more without a proper reproduce script.