Fixed live stream memory leak in Windows builds
This commit is contained in:
		
							parent
							
								
									6f933bdb97
								
							
						
					
					
						commit
						ccaec3d2f8
					
				
					 1 changed files with 18 additions and 2 deletions
				
			
		
							
								
								
									
										20
									
								
								src/io.cpp
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								src/io.cpp
									
										
									
									
									
								
							|  | @ -259,18 +259,34 @@ namespace Mist { | ||||||
| 
 | 
 | ||||||
|     //Keep track of registering the page on the track's index page
 |     //Keep track of registering the page on the track's index page
 | ||||||
|     bool inserted = false; |     bool inserted = false; | ||||||
|  |     int lowest = 0; | ||||||
|     for (int i = 0; i < 1024; i++) { |     for (int i = 0; i < 1024; i++) { | ||||||
|       int * tmpOffset = (int *)(metaPages[tid].mapped + (i * 8)); |       int * tmpOffset = (int *)(metaPages[tid].mapped + (i * 8)); | ||||||
|       int keyNum = ntohl(tmpOffset[0]); |       int keyNum = ntohl(tmpOffset[0]); | ||||||
|  |       if (!keyNum) continue; | ||||||
|  |       if (!lowest || keyNum < lowest){ | ||||||
|  |         lowest = keyNum; | ||||||
|  |       } | ||||||
|       int keyAmount = ntohl(tmpOffset[1]); |       int keyAmount = ntohl(tmpOffset[1]); | ||||||
|       if (keyNum == curPageNum[tid]){ |       if (!inserted && keyNum == curPageNum[tid]){ | ||||||
|         if (keyAmount == 1000){ |         if (keyAmount == 1000){ | ||||||
|           tmpOffset[1] = htonl(pagesByTrack[tid][curPageNum[tid]].keyNum); |           tmpOffset[1] = htonl(pagesByTrack[tid][curPageNum[tid]].keyNum); | ||||||
|         } |         } | ||||||
|         inserted = true; |         inserted = true; | ||||||
|         break; |  | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  | #if defined(__CYGWIN__) || defined(_WIN32) | ||||||
|  |     static int wipedAlready = 0; | ||||||
|  |     if (lowest && lowest > wipedAlready + 1){ | ||||||
|  |       for (int curr = wipedAlready + 1; curr < lowest; ++curr){ | ||||||
|  |         char pageId[NAME_BUFFER_SIZE]; | ||||||
|  |         snprintf(pageId, NAME_BUFFER_SIZE, SHM_TRACK_DATA, streamName.c_str(), mapTid, curr); | ||||||
|  |         IPC::releasePage(std::string(pageId)); | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|     //Print a message about registering the page or not.
 |     //Print a message about registering the page or not.
 | ||||||
|     if (!inserted) { |     if (!inserted) { | ||||||
|       INFO_MSG("Can't register page %lu on the metaPage of track %lu~>%lu, No empty spots left within 'should be' amount of slots", curPageNum[tid], tid, mapTid); |       INFO_MSG("Can't register page %lu on the metaPage of track %lu~>%lu, No empty spots left within 'should be' amount of slots", curPageNum[tid], tid, mapTid); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Thulinma
						Thulinma