Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: gpu/command_buffer/client/mapped_memory.cc

Issue 12087126: Fix shared memory leak on command buffer teardown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <functional> 6 #include <functional>
7 7
8 #include "../client/mapped_memory.h" 8 #include "../client/mapped_memory.h"
9 #include "../client/cmd_buffer_helper.h" 9 #include "../client/cmd_buffer_helper.h"
10 10
11 namespace gpu { 11 namespace gpu {
12 namespace {
13 void DeleteMemoryChunk(MemoryChunk* chunk) {
14 delete chunk;
15 }
16 }
17 12
18 MemoryChunk::MemoryChunk( 13 MemoryChunk::MemoryChunk(
19 int32 shm_id, gpu::Buffer shm, CommandBufferHelper* helper) 14 int32 shm_id, gpu::Buffer shm, CommandBufferHelper* helper)
20 : shm_id_(shm_id), 15 : shm_id_(shm_id),
21 shm_(shm), 16 shm_(shm),
22 allocator_(shm.size, helper, shm.ptr) { 17 allocator_(shm.size, helper, shm.ptr) {
23 } 18 }
24 19
25 MappedMemoryManager::MappedMemoryManager(CommandBufferHelper* helper) 20 MappedMemoryManager::MappedMemoryManager(CommandBufferHelper* helper)
26 : chunk_size_multiple_(1), 21 : chunk_size_multiple_(1),
27 helper_(helper) { 22 helper_(helper) {
28 } 23 }
29 24
30 MappedMemoryManager::~MappedMemoryManager() { 25 MappedMemoryManager::~MappedMemoryManager() {
31 std::for_each(chunks_.begin(), 26 CommandBuffer* cmd_buf = helper_->command_buffer();
32 chunks_.end(), 27 for (MemoryChunkVector::iterator iter = chunks_.begin();
33 std::pointer_to_unary_function<MemoryChunk*, void>( 28 iter != chunks_.end(); ++iter) {
34 DeleteMemoryChunk)); 29 MemoryChunk* chunk = *iter;
30 cmd_buf->DestroyTransferBuffer(chunk->shm_id());
31 delete chunk;
32 }
35 } 33 }
36 34
37 void* MappedMemoryManager::Alloc( 35 void* MappedMemoryManager::Alloc(
38 unsigned int size, int32* shm_id, unsigned int* shm_offset) { 36 unsigned int size, int32* shm_id, unsigned int* shm_offset) {
39 GPU_DCHECK(shm_id); 37 GPU_DCHECK(shm_id);
40 GPU_DCHECK(shm_offset); 38 GPU_DCHECK(shm_offset);
41 // See if any of the chucks can satisfy this request. 39 // See if any of the chucks can satisfy this request.
42 for (size_t ii = 0; ii < chunks_.size(); ++ii) { 40 for (size_t ii = 0; ii < chunks_.size(); ++ii) {
43 MemoryChunk* chunk = chunks_[ii]; 41 MemoryChunk* chunk = chunks_[ii];
44 chunk->FreeUnused(); 42 chunk->FreeUnused();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } else { 101 } else {
104 ++iter; 102 ++iter;
105 } 103 }
106 } 104 }
107 } 105 }
108 106
109 } // namespace gpu 107 } // namespace gpu
110 108
111 109
112 110
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698