<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang-format using over 5GB of RAM on a C file with many arrays"
href="https://bugs.llvm.org/show_bug.cgi?id=48363">48363</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-format using over 5GB of RAM on a C file with many arrays
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Formatter
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>tmatth@videolan.org
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=24228" name="attach_24228" title="Problematic source file">attachment 24228</a> <a href="attachment.cgi?id=24228&action=edit" title="Problematic source file">[details]</a></span>
Problematic source file
I noticed that clang-format was running out of memory on a system with only
3.75GB available. It turns out that for a specific file
(<a href="https://aomedia.googlesource.com/aom/+/c15883a29b9dc3c28caa03e22b7368ed8355d834/av1/common/quant_common.c">https://aomedia.googlesource.com/aom/+/c15883a29b9dc3c28caa03e22b7368ed8355d834/av1/common/quant_common.c</a>)
it is using over 5GB when invoked as follows:
/usr/bin/time -v clang-format -i --style=file aom/av1/common/quant_common.c
Command being timed: "clang-format -i --style=file
aom/av1/common/quant_common.c"
User time (seconds): 17.59
System time (seconds): 1.49
Percent of CPU this job got: 99%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:19.14
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 5479164 <----------------
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 1375531
Voluntary context switches: 2
Involuntary context switches: 136
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
The file in question is 12875 lines, and does contain a number of arrays, but
this still seems like it shouldn't be quite so memory intensive. I've seen the
same behavior with both clang 10 and 12.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>