Memory management problem




Memory management problem

Postby Mixony » 23. Apr 2017, 19:15

Got to the HTTP server
In InternetProtocolProvider::Send when malloc is called it goes into an infinite loop in
for(MemoryChunk* chunk = first; chunk != 0 && result == 0; chunk = chunk->next)
Did it happend to anyone.
Mixony
 
Posts: 24
Joined: 12. Mar 2017, 08:18

by Advertising » 23. Apr 2017, 19:15

Advertising
 

Re: Memory management problem

Postby Mixony » 24. Apr 2017, 21:17

I hate it when I get some bug search for it, dont find it, post it here and little bit after that I find the mistake.
I have put
result -> next = temp;
result -> prev = temp;
instead of just
result -> next = temp;
Mixony
 
Posts: 24
Joined: 12. Mar 2017, 08:18

Re: Memory management problem

Postby algorithman » 26. Apr 2017, 12:11

But temp is the new chunk behind the result chunk - why should result -> prev point to it? result->prev stays the same as before

maybe it wasn't set in the previous call? Do you set temp->prev = result? Do you initialize it for the first chunk in the MemoryManager constructor?
actually the pointer is never used except when freeing, so maybe the problem is in the free(...) method?
User avatar
algorithman
Administrator
 
Posts: 49
Joined: 2. Mar 2017, 11:40

Re: Memory management problem

Postby Mixony » 26. Apr 2017, 19:01

No. I set prev to temp on accident and it is what made problem. I overwrote what was there before.
Mixony
 
Posts: 24
Joined: 12. Mar 2017, 08:18


TAGS

Return to General Discussion

Who is online

No registered users

cron