It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
What are the most common/frequent memory leaks programmers use to run into when developing applications?
Interested in all kind of languages, would be nice if this could evolve into a community wiki where to see fixes for common leaks in different languages.
Update
I have a suggestion to limit this conversation to C related languages, .NET and Python. I think these are often used languages, and often beginners try to work with these. In case more languages are needed, edit.
EDIT this to add similar points.
In C++,
Forgetting to delete a pointer object.
In PHP,
PHP takes cares of memory management. It automatically deletes the memory of a variable when it goes out of scope.
On long running PHP scripts, it's a good idea to manually close unneeded socket connections, free result objects, etc.
In .NET
Failing to unregister event handlers.
C++
void Foo()
{
Object* newObject = new Object();
}
Object is initialised in new memory but is never deleted hence memory leak.
To clean up the memory for out of scope new'd objects one must use the delete keyword.
void Foo()
{
Object* newObject = new Object();
delete newObject;
}
.NET
Failing to unregister event handlers.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 days ago.
Improve this question
I am creating several scheduled tasks within my Laravel site using the schedule() function within the Console/Kernel object. It acceptable to place simple logic in the schedule() function (based on the explanation from the Laravel site):
$schedule->call(function () {
DB::table('recent_users')->delete();
})->daily();
However, if the logic needs to be more complicated (100 lines of code or more to decide which models to focus on) basic programming rules instructs us to break the code up into additional functions and classes, which can be then be called by schedule(). However, I am a bit confused as to where these functions/classes go. A few possibilities:
A Controller function, even though it does not use a route?
A trait, used by the Kernel?
Console command, even though it's never called from the console?
A helper?
(edit) Other classes that share the Kernel's namespace?
Another kind of class that functions like a Controller, but internally only? (Something that I am not aware of.)
Where do these classes/functions go?
====
There are many established patterns can be regarded as correct or incorrect, based on Laravel's intended use, regardless of opinion. Also, there are many valid ways in which Laravel can be used. Within this context, there are many opinions on the best way to do things, many of which could be considered correct. That said, there are framework design patterns which are beyond the scrutiny of opinion (for now.) We use routes to link URLs to Controllers (not jobs.) We access models from the controllers and not the other way around. My question is intended to discover an established pattern that I am not aware of, and not to debate opinions regarding these patterns.
Basically, I want to avoid building my site in a way that with prove blatantly embarrassing in the future, (especially regarding lesser well known site elements, such as jobs, scheduling and console commands) simply because I did not know Laravel facts.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Please take a look at my recent question here: Deadlock with no user code
How can you tell when the debugger is lying to you in this way? Other than, of course, showing that what it is telling you is impossible?
I don't like relying on that since I've seen so many 'impossible' states in a program that were in fact happening due to some subtle or esoteric problem.
Yes, those are pretty wacky stack traces, particularly the 1st one. Hard to theorize how that happened. It doesn't usually get that screwed up unless you debug optimized code.
Which is hint #1, never trust what the debugger tells you when you have to debug release built code. Strongly avoid it, you don't always have the luxury when you need to troubleshoot a deadlock however.
Strong hint #2 is paying attention to the code-flow. The normal one for a blocked thread, bottom to top in the Call Stack window, is yourcode => runtime (msvr120) => winapi layer (kernel32 et al) => native api (ntdll.dll). This is generally the case, there are a few cases where this flow is reversed, callbacks from the OS into your code, like window notification, thread-start (always at the far bottom of the stack for example), I/O completion.
Which is what's wacky, there is no realistic scenario where a low-level native api function like ZwWaitForSingleObject() could ever directly call into the C runtime library. That's bogus, only the top entry (Block) could be accurate. Yes, tough debugging that way.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
for e in 1..43 do
browser.link(:xpath,".//*[#id='buttonPrint']").click
sleep 3
puts browser.link(:xpath,".//*[#id='cmdNext']").click
end
browser.goto "http://www.cramster.com/solution/solution/912984"
for f in 1..33 do
browser.link(:xpath,".//*[#id='buttonPrint']").click
sleep 3
puts browser.link(:xpath,".//*[#id='cmdNext']").click
end
i want to have ruby go to the first url, click through all the buttons then go to the second url and click through all the buttons
right now ruby goes to the first url, performs the loop and does not see the second url
?
What you are trying to do is in violation of the Cramster terms of service.
G. No Bugs, Robots or other Automated
Programs. You may not use or introduce
bugs, robots or other automated
browsing or posting programs on or to
the Web Site at any time.
I therefore refuse to assist you and encourage other users to do likewise
Unless you want to come up with some credentials, other than a brand-new stackoverflow user account with no history and no details, and something that shows you are doing this with Cramster's permission (e.g. a tester working for them) we are done here.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 13 years ago.
We've all had them, errors or bugs that have lost us lots of time. I've seen it time and time again, the first 90% of the coding work for a given project takes 10% of the total time. It's that last 90% of the time you spend looking for that rogue bug that's really only about 10% of the coding work. That one thing that just doesn't want to work. Sometimes it's something big and other it's just that one character that was off.
What is the bug or error that has cost you and/or your team the most amount of time?
Once upon a time, I worked on a database project for an apartment management company. We had tables like Customer, CustomerStatus, Apartment, ApartmentStatus, and so forth. Queries I wrote would look like:
SELECT cu.Name, ap.ApartmentUnit, as.DateOccupied
from Customer cu
inner join CustomerStatus cs
on cs.CustomerId = cu.CustomerId
inner join ApartmentStatus as
on as.ResidentId = cu.CustomerId
and as.Status = 5
inner join Apartment ap
on ap.ApartmentId = as.ApartmentId
where cu.CustomerId = #CustomerId
This query and ones like it simply would not run, no matter how hard I tried, modified, or stared at it. It took days before I realised that my entirely reasonable table alias of "as" was a reserved word...
A Heisenbug is IMO one of the worst bug. Hunting such a beast is a real nightmare. Having that said, a Bohrbug, a Mandelbug, a Schroedinbug, a Phase of the Moon bug or a Statistical bug will give you serious headache too.
Getting Oracle to work, we are a SQL shop and now have to support Oracle, and nobody knew anything about Oracle.
Ive spent over 2 days trying to figure out a CSS issue that was breaking my site. It turned out to be that I mistook a curly brace for a parenthesis in one of the classes and my resolution is set too small to be able to tell very easily
In C++: 2 days trying to figure out why a particular script worked for everything except one particular class. Copying the class and renaming it didn't fix the problem.
Rewriting the class from scratch did fix the problem, but didn't seem to bring me any closer to the reason for the issue in the first place.
Diffing the files turned up nothing.
However, I then noticed that one of my new files, while visually identical, was only half the size of the original.
Different encodings in header and cpp file broke my script :)
Debugging some error that the Yahoo user interface library was spitting out. Spent a couple of days on it. It turned out that YUI spits out errors that are supposed to happen and don't need fixing.
3 months trying to track down an error in our engine rendering code. We had implemented our own custom vertex-pooling scheme, and it worked great in DX8. Once I upgraded the engine to DX9, all the geometry came out as garbled messes. Luckily I was able to turn that off with a #define, but hunting it down was a painful month of trial and error, and in the end it boiled down to setting the wrong parameter in an interface function that had changed in DX9 - we were setting firstvertex instead of startvertex, which caused the index lists to read the wrong vertices. Fun stuff.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm looking for a way to make programs appear (frequently) used, so that they would appear in the Start menu's "Recently Used Programs" (after a zero touch install).
I'm trying to figure out how Windows stores information related to program usage frequency.
The only (maybe) related things I can see being changed when I run a program from the Start Menu, are some (seemingly undocumented) BagMRU registry keys which have no meaning to me.
I did found a way to get programs pinned, but that's not what I'm looking for here.
Update: please see the comments for explanation why I would like to do this...
Update2: I'm making progress... Now I know where they keys are stored and I know that the keys are ROT13 "encrypted". And the second 4 bytes of the values are the counter.. http://blog.didierstevens.com/2006/07/24/rot13-is-used-in-windows-you’re-joking/
This ROT13(wikipedia) encryption thing is funny. Well, of course there is a reason. They don't want you to be able to find it by simple search.
Lol, and in windows 7 they are using Vigenère crypto! much better :D
At the risk of downvotes, this is not something you should be doing. The "Recently Used Programs" belongs to the owner of the computer, not your program.
If your program is as useful as you think it is, it will automagically show up there.
Raymond Chen has done quite a few articles as to why this sort of thing is a bad idea.
This rates among all those other bad ideas such as:
how can I force my program to be the handler for certain file types?
how can I keep my program always on top.
how can I annoy my users by making decisions for them when they previously had the power to make their own decisions as to how their software was configured? :-)
Update:
A couple of things you may want to try.
Copy a program (explorer.exe) to axolotl.exe and run it enough times to get it on the list. Then search the registry for it (assuming there's not another axolotl.exe somewhere on your disk).Be aware that some strings are stored as Unicode so it might not be a simple search. It also wouldn't surprise me if MS encoded them some way to make this more difficult.
Microsoft's sysinternals have a tool that can monitor the registry (regmon, look here, you could run that while you run a program a few times to see what gets updated when it's added to the list.
I found what I was looking for here:
http://blog.didierstevens.com/2006/07/24/rot13-is-used-in-windows-you’re-joking/
If this is possible, I do recommend against it. It is, as you say, undocumented behaviour and circumvents the intended usage of the frequently used programs list. What's wrong with a desktop icon and quick launch shortcut?
Use Win32 Shell COM interfaces
It has been explained for decades, like for all undocumented features, on Google Groups (Win32), same method than on W95..