Hi all,
I just played with Java file system API, and came down with the following function, used to copy binary files. The original source came from the Web, but I added try/catch/finally clauses to be sure that, should something wrong happen, the Buffer Streams would be closed (and thus, my OS ressources freed) before quiting the funct...
Consider the code:
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.createStatement(myQueryString);
rs = ps.executeQuery();
// process the results...
} catch (java.sql.SQLException e) {
log.error("an error!", e);
throw new MyAppException("I'm sorry. Your query did not work.");
} finally {
ps.close();
rs.cl...
The idea of automatic memory management has gained big support with new programming languages. I'm interested if concepts exists for automatic management of other resources like files, network-sockets etc.?
...
In C++ we have Resource Acquisition Is Initialization (RAII) pattern, which extremely simplify the resource management. The idea is to provide some wrapping object for any kind of resources. The wrapping object's destructor is then responsible for releasing the resource, when it's going out of its scope. For example:
{
auto_ptr<int>...
I am looking for an algorithm to apply to the "dishwasher at work" problem.
While it is great to be able to put dirty coffee cups etc. in it, you quickly run into the "what is the state of the dishes?" dilemma. If you walk up to the kitchen, can you take dishes from the dishwasher because they are clean and just not put away? Can yo...
I'm considering developing an app for Google App Engine, which should not get too much traffic. I'd really rather not pay to exceed the free quotas. However, it seems like it would be quite easy to cause a denial of service attack by overloading the app and exceeding the quotas. Are there any methods to prevent or make it harder to excee...
How to utilize programmers effectively when they don’t have Enough Work?
...
Hi folks!
I created two files in the App_GlobalResources folder:
SiteResources.en-US.resx
SiteResources.sp-SP.resx
Both contain a value for "SiteTitleSeparator".
Here is what I am trying to do (The following line always returns null):
string sep = (string)GetGlobalResourceObject("SiteResources", "SiteTitle");
Note, that the Cultu...
As I've developed my app, I have imported and incorporated a lot of images, sounds, etc. I guess I could just write a shell script that greps the source code, but I'm wondering if there's an existing that will identify any unused resources in my project.
Thanks!
...
If I implement a object with IDisposable, should all objects that own that object implement it as well, even if they have no other resources to release?
...
Our shop has developed a few WEB/SMS/DB solution for a dozen client installations. The applications have some real-time performance requirements, and are just good enough to function properly. The problem is that the clients (owners of the production servers) are using the same server/database for customizations that are causing problems...
what is the proper way of closing a tread after running a query against a MySql database from a windows form in C#.
is a simple open close enough like this?
conn.Open();
//querycode
conn.Close():
...
I wrote a program that is based completely on a single text file: I read the file, store the information, then search the information, etc. So, for the program to work, the file just has to be present and detectable by the program.
I use eclipse, so I put the file is in the default resources map (src/main/resources). At the start of my p...
In holy wars about whether garbage collection is a good thing, people often point out that it doesn't handle things like freeing file handles. Putting this logic in a finalizer is considered a bad thing because the resource then gets freed non-deterministically. However, it seems like an easy solution would be for the OS to just make s...
So here is an interesting question. When you have an embedded device with multiple communications ports, and potentially multiple tasks, each with their own protocols, needing to access these ports at the same time, how do you manage control and access to the port resources?
I am running an embedded OS (FreeRTOS to be precise) so I hav...
I see a lot of RAII example classes wrapping around file handles.
I have tried to adapt these examples without luck to a character pointer.
A library that I am using has functions that take the address of a character pointer (declared like get_me_a_string(char **x)).
These functions allocate memory for that character pointer and leave ...
I have seen many examples of ARM (automatic resource management) on the web for Scala. It seems to be a rite-of-passage to write one, though most look pretty much like one another. I did see a pretty cool example using continuations, though.
At any rate, a lot of that code has flaws of one type or another, so I figured it would be a goo...
Hello everyone :)
I'm very new to anything involving Component Object Model, and I'm wondering if this method of managing calls to CoInitalize/CoUninitalize makes sense:
COM.hpp:
#pragma once
namespace WindowsAPI { namespace ComponentObjectModel {
class COM
{
COM();
~COM();
public:
static void Setup();
};
}}
COM.cpp:
...
I'm a C++ amateur. I'm writing some Win32 API code and there are handles and weirdly compositely allocated objects aplenty. So I was wondering - is there some wrapper class that would make resource management easier?
For example, when I want to load some data I open a file with CreateFile() and get a HANDLE. When I'm done with it, I sho...
A trivial question perhaps, but I'm interested in the answers. I'm currently refactoring some very large monolithic string resource files (one dumpster resource file per project, in about 30 projects). I'm splitting them such that we follow a convention for our files and make the strings easier to find and manage when coding.
Generally...