[Mono-bugs] [Bug 69474][Nor] New - Eliminate buffer in mono_image_create_pefile

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 14 Nov 2004 11:36:48 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by bmaurer@users.sf.net.

http://bugzilla.ximian.com/show_bug.cgi?id=69474

--- shadow/69474	2004-11-14 11:36:48.000000000 -0500
+++ shadow/69474.tmp.1103	2004-11-14 11:36:48.000000000 -0500
@@ -0,0 +1,70 @@
+Bug#: 69474
+Product: Mono: Runtime
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: bmaurer@users.sf.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Eliminate buffer in mono_image_create_pefile
+
+in reflection.c, mono_image_create_pefile, we create a buffer that is the
+size of the pe file we are generating. In bootstrapping mcs, this accounts
+for almost a megabyte of memory allocation:
+
+==27731== 1048576 bytes in 1 blocks are still reachable in loss record 1094
+of 1094
+==27731==    at 0x3414AD12: realloc (vg_replace_malloc.c:197)
+==27731==    by 0x70E630: g_realloc (in /usr/lib/libglib-2.0.so.0.400.0)
+==27731==    by 0x8089F5C: make_room_in_stream (reflection.c:189)
+==27731==    by 0x808A129: mono_image_add_stream_zero (reflection.c:261)
+==27731==    by 0x80923E7: mono_image_create_pefile (reflection.c:4656)
+
+We also do not free this memory. It would be best, however, never to create
+it and write directly to the file.
+
+We also need to work on freeing other memory once we generate the image:
+
+==27731== 524288 bytes in 1 blocks are still reachable in loss record 1093
+of 1094
+==27731==    at 0x3414AD12: realloc (vg_replace_malloc.c:197)
+==27731==    by 0x70E630: g_realloc (in /usr/lib/libglib-2.0.so.0.400.0)
+==27731==    by 0x8089F5C: make_room_in_stream (reflection.c:189)
+==27731==    by 0x808A0D1: mono_image_add_stream_data (reflection.c:245)
+==27731==    by 0x808B4AA: method_encode_code (reflection.c:981)
+==27731==    by 0x808BC41: mono_image_basic_method (reflection.c:1237)
+
+==27731== 262144 bytes in 1 blocks are still reachable in loss record 1091
+of 1094
+==27731==    at 0x3414AD12: realloc (vg_replace_malloc.c:197)
+==27731==    by 0x70E630: g_realloc (in /usr/lib/libglib-2.0.so.0.400.0)
+==27731==    by 0x8089F5C: make_room_in_stream (reflection.c:189)
+==27731==    by 0x808A0D1: mono_image_add_stream_data (reflection.c:245)
+==27731==    by 0x809131E: mono_image_insert_string (reflection.c:3979)
+==27731==    by 0x35609887: ???
+
+==27731== 98304 bytes in 1 blocks are still reachable in loss record 1089
+of 1094
+==27731==    at 0x3414AD12: realloc (vg_replace_malloc.c:197)
+==27731==    by 0x70E630: g_realloc (in /usr/lib/libglib-2.0.so.0.400.0)
+==27731==    by 0x8089EBA: alloc_table (reflection.c:173)
+==27731==    by 0x808F169: mono_image_get_type_info (reflection.c:2870)
+==27731==    by 0x80911A3: mono_image_build_metadata (reflection.c:3918)
+==27731==    by 0x35648CD2: ???
+
+==27731== 65536 bytes in 1 blocks are still reachable in loss record 1084
+of 1094
+==27731==    at 0x3414AD12: realloc (vg_replace_malloc.c:197)
+==27731==    by 0x70E630: g_realloc (in /usr/lib/libglib-2.0.so.0.400.0)
+==27731==    by 0x8089F5C: make_room_in_stream (reflection.c:189)
+==27731==    by 0x808A027: string_heap_insert (reflection.c:207)
+==27731==    by 0x808BC03: mono_image_basic_method (reflection.c:1232)
+==27731==    by 0x808C090: mono_image_get_method_info (reflection.c:1399)