NoLeak - include to help you find memory leaks (PB5.20)

Share your advanced PureBasic knowledge/code with the community.
User avatar
mariosk8s
Enthusiast
Enthusiast
Posts: 103
Joined: Wed Apr 06, 2011 11:37 am
Location: Hüfingen, Germany
Contact:

Re: NoLeak - include to help you find memory leaks (1.3)

Post by mariosk8s »

This is a real cool add-in.
Now i only wonder if there's a way to get a call stack of some sort to be included.
That way when an allocate is in a nested function that's called from a lot of different places, we could find out who the evildoer was.
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Re: NoLeak - include to help you find memory leaks (1.3)

Post by sec »

@luis: Could you please update this to last version?

Thanks.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: NoLeak - include to help you find memory leaks (1.3)

Post by luis »

sec wrote:@luis: Could you please update this to last version?
Doesn't it work already ? I tried with the last 5.20 beta and unless I'm missing something it does.

Only problem I see is in the demo the allocation of 99,999,999,999 bytes does not fail, I seem to recall in older version did so (don't remember which version).

Why does not fail BTW ? I understand the pointer returned is not to physical memory but nevertheless... but maybe what's changed is the underlying OS and not something inside PB ?

Practically allocatememory() never fails today until something horrible happen with the entire OS running out of resources ?


EDIT: now there is something else I don't understand. Currently PB should fill with zeros the allocated memory (by default).
So the OS should be forced not only to "virtually" reserve the memory, but to actually commit it since the memory is actually accessed.
How can the allocation above be successful then ?

EDIT 2: actually it does fail, phew, there was an overflow so the allocated memory was a lot less. I'll change it in the version updated for PB 5.20.
Last edited by luis on Thu Sep 05, 2013 9:24 pm, edited 1 time in total.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: NoLeak - include to help you find memory leaks (1.3)

Post by luis »

@sec

You asked me to update the code to the latest PB version.
I took the time to check it, and I've reported back.
The question I made was not a rhetorical one.
Doesn't it work already ? I tried with the last 5.20 beta and unless I'm missing something it does.
"Have you tried turning it off and on again ?"
A little PureBasic review
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Re: NoLeak - include to help you find memory leaks (1.3)

Post by sec »

@luis: I am not expert at hunting the bugs.

I am trying code at your first post with 5.20, it says missing parameters at AllocateMemory, ReAllocateMemory, ...

Thanks
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: NoLeak - include to help you find memory leaks (1.3)

Post by luis »

Really ? I'll test it again. One of us is probably drunk, mybe I'm the one :mrgreen:
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: NoLeak - include to help you find memory leaks (1.3)

Post by luis »

I just tried, I had the doubt of have used the wrong compiler.
I tried with 5.20 beta 16, x86, under Windows.

It works. :?:
"Have you tried turning it off and on again ?"
A little PureBasic review
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Re: NoLeak - include to help you find memory leaks (1.3)

Post by sec »

luis wrote:Really ? I'll test it again. One of us is probably drunk, mybe I'm the one :mrgreen:
Yes :mrgreen:

My project has 'refresh' feature', it is increasing 4K after each 'refresh' . bUt i can't find where is root of cause problem.
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Re: NoLeak - include to help you find memory leaks (1.3)

Post by sec »

luis wrote:I just tried, I had the doubt of have used the wrong compiler.
I tried with 5.20 beta 16, x86, under Windows.

It works. :?:
for example:

Code: Select all

  *Buffer = AllocateMemory(1024, #PB_Memory_NoClear)
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: NoLeak - include to help you find memory leaks (1.3)

Post by luis »

AAAAAH, I think I understand.

You are telling me it doesn't work wit YOUR code, not with MY EXAMPLE.

Right ?

Problem is I was testing what is posted HERE and thought you were doing the same, logically :wink:


OK, newer PB versions added a new param to allocatememory and in your code you are using it.

The code need to be updated to work with that, I'll do it as I have a moment, probably this evening.

I'll check the other commands too.

OK ? Bye!
"Have you tried turning it off and on again ?"
A little PureBasic review
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Re: NoLeak - include to help you find memory leaks (1.3)

Post by sec »

luis wrote:AAAAAH, I think I understand.

You are telling me it doesn't work wit YOUR code, not with MY EXAMPLE.

Right ?

Problem is I was testing what is posted HERE and thought you were doing the same, logically :wink:


OK, newer PB versions added a new param to allocatememory and in your code you are using it.

The code need to be updated to work with that, I'll do it as I have a moment, probably this evening.

OK ? Bye!
Yes, thanks you :mrgreen:
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: NoLeak - include to help you find memory leaks (1.3)

Post by luis »

@sec

Should be ok, give it a try and let me know if I forgot something.
Thanks.
"Have you tried turning it off and on again ?"
A little PureBasic review
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Re: NoLeak - include to help you find memory leaks (1.3)

Post by sec »

luis wrote:@sec

Should be ok, give it a try and let me know if I forgot something.
Thanks.
I get macro error:

Code: Select all

Global remote_host_img = _CatchImage (#PB_Compiler_File, #PB_Compiler_Line, 9, ?my_png,  $7FFFFFFF)
User avatar
mariosk8s
Enthusiast
Enthusiast
Posts: 103
Joined: Wed Apr 06, 2011 11:37 am
Location: Hüfingen, Germany
Contact:

Re: NoLeak - include to help you find memory leaks (1.3)

Post by mariosk8s »

sec wrote:My project has 'refresh' feature', it is increasing 4K after each 'refresh' . bUt i can't find where is root of cause problem.
Try, checking that you call ClearStructure on all the Structs you free. NoLeak doesn't catch that and it can cause leaks.
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Re: NoLeak - include to help you find memory leaks (1.3)

Post by sec »

mariosk8s wrote:
sec wrote:My project has 'refresh' feature', it is increasing 4K after each 'refresh' . bUt i can't find where is root of cause problem.
Try, checking that you call ClearStructure on all the Structs you free. NoLeak doesn't catch that and it can cause leaks.
@mariosk8s: Thanks,

Never hear about ClearStructure before.

Code: Select all

Threaded NewMap cserver.serverinfo()
ClearMap(cserver()) is equal ClearStructure(@cserver(), serverinfo) ?
Post Reply