w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
SqLite in memory database : CREATE TABLE does not work?
This happens when your ORM closes your connection, and reopens it. That will reset the sqlite in-memory database to its default state; i.e. empty. The same thing happens with NHibernate unless you set connection.release_mode = close (the default is after_transaction. I'm not familiar with Entity Framework, but I expect a similar setting or using the DataContext(IDbConnection) constructor which is documented as "If you provide an open connection, the DataContext will not close it." The same documentation also states "In a System.Transactions transaction, a DataContext will not open or close a connection to avoid promotion." which may be a cleaner solution. Using some Reflector magic shows that it's SQLiteConnection.Open that calls (via SQLite3.Open) sqlite3_open_interop (if you're using

Categories : C#

Sqlite database and memory cache for thumbnail storage
You shouldn't store the images as bytes, you should store the images as files in the cache folder and in you db you should only store the paths towards the images (or the name of the images if you know the folder). You should cache the thumbnails also, it will increase the speed when he looks through the list of thumbnails (resizing an image takes some time). P.S. You can use some 3rd part libraries for this.

Categories : Android

fork failures: Cannot allocate memory
To check for memory leaks you might like to run the program under Valgrind: http://valgrind.org To get/set limits from the console/shell there is the ulimit command available. From inside the program the system calls getrlimit()/setrlimit() provide this functionality. Another workaround for situations where memory might get tight due to fork()ing would be to use vfork() immediately followed by a call to a member of the exec*() family of functions. From man vfork: vfork() is a special case of clone(2). It is used to create new processes without copying the page tables of the parent process. It may be useful in performance-sensitive applications where a child is created which then immediately issues an execve(2). vfork() differs from fork(2) in that the parent is sus

Categories : C

When testing NHibernate with a SQLite In Memory configuration, how do you create another database?
I had this very same problem - (no longer since we moved from Sqlite to Sql Server LocalDB for tests). I do still have the code, what we did was provide a component which configures whether to use schemas or not, thus: public class SqlLiteMappingsHelper : IMappingsHelper { public string TextColumnTableSpecification { get { // see sqlite faqs re: all varchars are very large whatever you specify // http://www.sqlite.org/faq.html#q9 return "nvarchar(10)"; } } public bool SchemasEnabled { get { return false; } } } (and one similar for sql server with SchemasEnabled = true) - in the web app you tell your IoC container to use the sql server

Categories : Sqlite

glibc detected; memory corruption
Sometimes output gets stuck in the write buffer and never actually gets written to the console if the program exits prematurely. Calling fflush(stdout); will help you determine if this is the case. Or else use fprintf(stderr, ...) for debug output, since stderr is unbuffered. More likely, however, is that your program actually does crash inside the one major task that takes place between printing "realizing" and "blur initial"... the Image<uint8_t> copy constructor. Why you're passing by value and causing a copy is beyond me, I would prefer a const reference there to avoid copying a large object. Still, if you have a bug in your copy constructor it's definitely worth finding and fixing that first.

Categories : C++

Can unsafe code in C# cause memory corruption?
Accessing a pointer to an invalid random memory location If it is a read, it is safe. If it was a write it is unsafe if the memory location happened to be valid, but you did not own it. You'll be scribbling over random memory locations. And as a corollary, is it safe to catch AccessViolationExceptions from unsafe code? No, because that exception tells you a) that you have a bug and b) that memory might be corrupted which cannot be repaired. Catch it and tear down the process asap.

Categories : C#

Heap corruption while freeing memory C
C arrays are zero based so the line ch_number[strlen(error) - 2] =''; writes one byte beyond the end of ch_number. The effects of doing this are undefined but it sounds like you've written to a guard word used by the heap manager to detect exactly this sort of corruption. If you want to add a null terminator to ch_number, you need to allocate an extra byte of memory ch_number = malloc(strlen(error) - 1);

Categories : C

Corruption of the heap during memory allocation
The line head=(SyDetails) malloc(sizeof (SyDetails)); is wrong in two ways. First, the reason why you are corrupting the memory: SyDetails is a pointer, so this will allocate only sizeof(pointer) bytes which is less than the necessary sizeof(struct SystemDetails) - for which you should change it. Even better, change it to sizeof(*head) to be safe in case the type of head ever changes. The second thing is that in C, you should not cast the return value of malloc(). All in all: head = malloc(sizeof(*head)); is what you really want.

Categories : C

run glibc memory corruption test manually
enabling debug info with -g causes more issues to be reported. That is not how glibc heap corruption detection works. Is there any way to call the glibc heap metadata consistency check manually Yes: http://www.gnu.org/software/libc/manual/html_node/Heap-Consistency-Checking.html See also MALLOC_CHECK_ environment variable description.

Categories : Debugging

memory corruption passing string from c++ dll to mono (C#)
You are returning descstr.c_str() which is declared on the stack in your getdescstring function. The memory it refers to is invalid as soon as the function returns. Try making descstr.c_str() so it stays in scope (e.g. as a global variable).

Categories : C#

Is there any possiblity of Memory corruption or segment fault?
Don't confuse processes and threads. With processes, nothing can happen at all. With threads, if your function works straightforward and doesn't touch or use any shared resources, it should work as well.

Categories : C

getting heap corruption detected when freeing memory with calloc and changed stdout
You forgot the terminating '' when you calculate the needed length of file_full_name: You only have strlen(file_number)+10+4 with 10 == strlen(file_name) and 4 == strlen(file_ext). Add 1 for `'.

Categories : C++

How to directly insert images and other type of files into SQLITE database as like in mysql and sql by using query?
You should use a BLOB type, which allows you to store raw binary data. I don't know which is the maximum allowed size, though. I would create a table like the following: CREATE TABLE `test`.`pic` ( `idpic` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `caption` VARCHAR(45) NOT NULL, `img` BLOB NOT NULL, PRIMARY KEY(`idpic`) ); Then just read the image using standard I/O and write the data to the img column, just as you would with a file.

Categories : C

From numpy matrix to C array. Segmentation fault (memory corruption) on 64bit architecture
Here you want to allocate memory for pointers to float: float **v; v=(float **)malloc((size_t) (n*sizeof(float))); but you do allocated memory for floats themselfes. On a 32bit system pointers need 4 bytes, so this works. On a 64bit system pointers need 8 byte, so you might like to change the above line to be: float ** v = malloc(n * sizeof(float*)); or even more secure to float ** v = malloc(n * sizeof(*v)); Btw: In C it is not needed to caste the result of malloc/calloc/realloc nor is it recommended. Even more it is dangerous to do so as it might hide awful mistakes.

Categories : C

Which is better Ready XML database or convert it to SQLite? Can I put converted SQLite database on package(.apk)?
Here's how you can put a sqlite database into your apk, or actually have it load for your app if it doesn't yet exits. You create or add the relevant parts to your DBHelper/DBContractor. You must put your sqlite database in /res/assets folder of your project. That's where it's going to read it from. public class DbHelper extends SQLiteOpenHelper { public static String DATABASE_PATH; public static final String DATABASE_NAME = "yourdatabasename.db"; private static final int DATABASE_VERSION = 1; private Context context; private SQLiteDatabase db; public DbHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); this.context = context; String packageName = context.getPackageName(); DATABASE_PATH = String.format("//data//data//%s//databases//",

Categories : Android

In memory Database to test mysql database operation API using in memory database with maven
Have a look at DBUnit - their how-to is at http://dbunit.sourceforge.net/howto.html It does exactly what you're looking for. The DBunit site has lots of examples. What I do is the following: set up the d/b in the @Before method, so each test gets a clean fixture. An example of the @Before method is: Connection conn = dataSource.getConnection(); try { IDatabaseConnection connection = new DatabaseConnection(conn); DatabaseConfig config = connection.getConfig(); config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory()); DatabaseOperation.CLEAN_INSERT.execute(connection, loadDutyData()); DatabaseOperation.CLEAN_INSERT .execute(connection, loadHelperDa

Categories : Java

Unlogged out user if power failures/unplugging computer, how to handle power failures
Handling sudden power failures in an application running on the computer with the power failure simply isn't possible. When the power fails the computer will stop running and the application will receive no warning. For cases where the power mode changes, as in computer being suspended or shut down, you can use the following events on SystemEvents SystemEvents.PowerModeChanged SystemEvents.SessionEnding Both of these can be raised in response to specific power events on the computer. This may be what you are looking for

Categories : C#

unable to open database file in sqlite (using finisar.sqlite)
So a number of things could be going wrong here: The folder the SQLite database is in, you don't have Write permissions to. The database is already open by another SQLiteConnection. The connection string is wrong. I think this one is unlikely because it's clearly a variable you're pulling the connection string from and I have to believe other times you wanted data you used the same string. To remedy #2 you should always access your data like this: using (SQLiteConnection c = new SQLiteConnection(f_strConnStr)) { c.Open(); ... }

Categories : C#

Flash Embedded FLV Memory Leak
How much is your memory increasing? If it's starting at ie. 80 MB and slowy increasing ie. to 140, and then either staying there or decreasing to 120 and again going slightly up, then there's no need to worry. Unfortunately that's how the Flash GC works. Even if you're not leaking any memory it will slowly show memory increase (and then sudden bob down, as the GC collects trash, and again slowly up). However, it could be also that you have a real memory leak, but for that to assess, you'd need to post some code. Btw, using memory-pools is a great idea in games, good you're doing it already.

Categories : Actionscript

How to write to flash memory using inline assembly?
It looks like you arrived at the solution already: the problem is in using BANKED. EECON2 and the like are Special Function Registers (SFRs) that reside in bank 15. The fastest way to access them is to use ACCESS, which ignores the bank register in computing the address. It looks like in the assembly language you are using, ACCESS means 0 and BANKED means 1. One of these values is required in the movwf instruction. The datasheet uses the actual numbers in its examples, instead of symbolic constants. The datasheet also explains the how the RAM is banked. Basically, there is as register that holds 4 bits representing banks 0 to 15. This number gets prepended to the 8 bit number given to the instruction, to give all 12 bits. This allows faster execution. To store in the correct location,

Categories : C

Modelling a Flash or Non-Volatile Memory Activity in SIMULINK model
You basically need a memory. There are possibly multiple ways of doing this. Delay is a memory. You can set its initial conditions for start up values. You can either put the Delay inside an enabled sub-system to write new values or you can use a mux to write new value or previous value from output of delay. You can use a MATLAB Function block and declare a persistent variable in it. You can initialize this inside a check for "is empty(persistent_var_name)" and then read or write into it. One more way is how the original question implements it using "Data Store".

Categories : Misc

how to download apk file to nand flash internal memory not having SD Card?
How can I find the path of download folder in NandFlash? The same way you hopefully found the "path of download folder" everywhere else: Environment.getExternalStoragePublicStorageDirectory(Environment.DIRECTORY_DOWNLOADS)` You can read more about getExternalStoragePublicDirectory() in the documentation. You might also consider reading the more general documentation about external storage.

Categories : Java

Flash AS3 Loading XML from server (from Flash Pro AND Flash Builder)
For anyone else having this problem, I was talking to people from beanstalk and it seems that I was just doing it wrong. I was trying to use the repository for version control and hosting the assets when really subversion repositories should only be used for backing up your files and versioning. I went with Amazon S3 which is basically exactly what I was looking for, a spot "in the internet" where I could drop my swf, xml, image, sound files and have a path generated for my games to reference. It ended up looking something like this: _xmlPath = "https://s3.amazonaws.com/xmlFiles/1234235/explosion_guy.xml";

Categories : Xml

Where to put flash files in rails?
I would put it into assets. That is what it is. Then modify the html they give you to look for it in the right place, which will vary depending on your setup. I use a CDN, so my assets are in the cloud and accessed through a subdomain like: assets1.example.com/assets/file-abc123.swf

Categories : Ruby On Rails

Playing Flash swf files in XNA
Sorry, but this is not possible without extreme hard work that's just not going to be within your reach. (Or some painfully awkward method, like embedding a Webpage below your game) On the bright side - there's pretty much no need for .swf embedding. Anything flash can do, XNA can do better! Use animated images or videos for live backgrounds / cutscenes - or program them yourself in XNA using manipulation of static images - if you need help with that, post a new question asking for help with some specific thing you need done. Also, if you want, you can ask for help converting Flash Actionscript to its C#/XNA equivalent - it can be done without too much work by anyone with a little experience in both languages.

Categories : C#

android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
I don't think this is your problem, but it still looks pretty bad to me. You have a duplicate layer of com.examples.quote in your project. Your Activity section in your AndroidManifest.xml should look more like this: <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> You may even have your classes under src/com.example.quotes/com.example.quotes instead of just in com.example.quotes. I'm not sure if this is causing your problem. But it looks a bit messed up. All your other s

Categories : Android

playing flash files in iphone
No, there is no way to display a Flash file (SWF) in the iPhone browser. If you have access to the source of the Flash files in the application, it may be possible to export them as HTML5 from the Flash builder. There's no way to do this conversion just from the SWFs, though. As an aside: your application won't work on many newer smartphones either - under Android, Adobe has dropped support for the Flash plugin on current versions of the OS, and it's not supported at all on current versions of Windows Mobile or Blackberry OS. Sites which depend on Flash content are effectively unusable on mobile at this point.

Categories : Iphone

Android: copy sqlite database from asset issue (i got a database without any tabe after all)
AFAIK, the function onCreate() only call at the first time we access to database and the database isn't exist. So i think that put some code here to copy database is ok. But look like there are something... that i'm not clearly at this time. When i try to put my code to this function (copy database from data asset), the database was created have the same size with mine but there are no table. I just follow the solution that mentioned at Database not copying from assets. And it working properties now! I just see only one different thing that he call copy database in constructor instead OnCreate and he call getReadableDatabase() at first. Anyway, i have to complete what i have started then come back to this topic since i'm not satisfy with the answer. If some one have the same issues, tr

Categories : Android

AS3/Flash/Air: Database sharing
You can write to the file, but it won't work if multiple application tries to write the file at the same time. And, lets say app A changes one data, and app B changes another data. App A writes the new XML, then B writes its own version of the XML without acknowledging the changes from A. The changes from A are lost. One way to go here is SQLite. Natively supported in AIR. But then again, you can not write the file at the same time from 2 different apps. AIR is supposed to handle those writing issues, but i already experienced some problems with it. A much better way to go here would be setting a SQL server up (or any other real DB server, i am no expert) and some php interface. Maybe AMFPHP : http://gotoandlearn.com/search.php?q=amf, or simply use urlloaders ...

Categories : Actionscript

is there any way to create an windows phone app with swf flash files?
No, you can't directly display a swf on WP8. You'd basically have to write flash player for WP. It would really be in your best interest to join the rest of the web and move away from flash/flash player. Most systems are actually dropping support for it in favor of HTML5. If you're still interested in app development for mobile systems there are plenty of tutorials on using HTML5 to create cross platform apps, as well as development kits which will have the foundation for a lot of what you might like to do. One such framework can be found here, but like I said there are many out there.

Categories : Windows Phone 8

SQLite on iPhone, can't get one row result
So it looks like you're trying to find the number of rows in your USER table with the same user_id? You should use a SQL query like "SELECT COUNT(*) AS answer FROM USER WHERE user_id = %d". This will produce one row of output, and that output will have an entry 'answer' where the value is the number you want. You'll need to use the SQLite API to read 1 row, and take the value from its 'answer' entry. So you'll call sqlite3_step() one time, sqlite3_column_count() one time to double-check that you received a result (it should return 1) and sqlite3_column(statement, 0) one time, to get the result from the first column.

Categories : IOS

SQLite same result after update
In your update method you are using a transaction, but you never set the result as successful, so everytime you reach db.endTransaction() a rollback is performed. That's why your update isn't stored. The changes will be rolled back if any transaction is ended without being marked as clean (by calling setTransactionSuccessful). Otherwise they will be committed. You need to use db.setTransactionSuccessful(); when your update is finished without errors. In your code, it should be after both your db.update.

Categories : Android

Reading txt files and parsing them fast using c++ and boost memory mapped files
Streams are slow. Part is because the constraints that apply to them are onerous, part is because implementations have a tendency of being poorly optimized. Try using Boost.Spirit parsers. While the syntax takes a bit of getting used to and compilation can sometimes be very slow, the runtime performance of Spirit is very high.

Categories : C++

AnyDac - How to disconnect from in-memory sqlite db?
ADConnection.Close completely remove in-memory SQLite DB. With next ADConnection.Open, explicitly or implicitly, new empty in-memory DB is created. This can be easy confirmed by simple test: ADConnection1.Open; ADConnection1.ExecSQL('create table TEST (A, B)'); ADConnection1.ExecSQL('insert into TEST values (1, 2)'); // show value of TEST.A ShowMessage(VarToStr(ADConnection1.ExecSQLScalar('select A from TEST'))); ADConnection1.Close; ADConnection1.Open; // next statement generates exception - [FireDAC][Phys][SQLite] ERROR: no such table: TEST ShowMessage(VarToStr(ADConnection1.ExecSQLScalar('select A from TEST')));

Categories : Delphi

SQLite insert :memory: performance
Your code is creating new parameter objects in each loop iteration. You should reuse them and just change their values; something like this: ... var paramRowID = cmd.CreateParameter(); paramRowID.ParameterName = "@RowID"; cmd.Parameters.Add(paramRowID); // same for the other parameters foreach ... { paramRowID.Value = row["RowID"]; // same for the other parameters cmd.ExecuteNonQuery(); } However, SQLite has no mechanism similar to BulkCopy; you always have to insert records one by one.

Categories : Sqlite

Make the media uploader accept flash files
This is by design. To allow this you'll need to either change the core or install a plugin such as http://wordpress.org/plugins/mime-types-extended/. There are other plugins here: http://wordpress.org/plugins/search.php?q=mime Edit: According to this tutorial, you can infact define additional mimetypes easily.

Categories : PHP

get one result at a time from database (when more than one result exists)
What is the query/code you are using to get all of column two as a string? It is always a good idea to test your query in the database system itself or you could use SQLFiddle to ensure you are getting the results you are expecting from your query From the Doc: A ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set. Read the rest of Java Doc for ResultSet A typical approach to getting values from the data base is to //Construct a statement String yourStatement = "Select COLUMN_B from aTable WHERE COLUMN_A LIKE '

Categories : Java

Strange result in SQLite query
Select idRuleForeign... returns multiple results, yes ({1, 2, 3}). However, you then say "give me the rule where idRule = {SET}", and sql doesnt like this. I believe what is happening is that it is instead taking the first result only and giving you that. The solution is to use joins. Inner selects like that, while work most of the time, can REALLY slow down your query. If I got my syntax correct, the following should do what you need: SELECT r.rule FROM rules r JOIN rulesXfilter rf ON r.idRule = rf.idRuleForeign JOIN filters f ON f.idFilter = rf.idFilterForeign WHERE f.name = 'Filter1'

Categories : Sqlite

Sqlite query for multiple result
Try sending List<String> public List<String> getItemNameRbPrice(long lprice) throws SQLException{ String[] column = new String[]{Pro_ID, Pro_Name, Pro_Price, Pro_Description, Pro_Date}; Cursor c = ourDatabase.query(TABLE_NAME, column, Pro_Price + "=" + lprice, null, null, null, null); List<String> lst = new ArrayList<String>(); if (cursor.moveToFirst()) { do { String name = c.getString(1); lst.add(name); Log.v(name,name + ("zz")); } while (cursor.moveToNext()); } return lst; }

Categories : Android

is AS3 AIR suitable for database applications? is SQL in AS3 as fast as SQL in C#? WPF vs FLASH
A relational storage won't be slower depending on the consumer platform. What makes sense is: The data access strategy. Cache or not cache data. Writing efficient queries. Properly handling database connections. ... In the other hand, WPF is a Windows-only desktop-oriented applications UI framework. It's great and far superior compared to something like Adobe Air, but it's not cross-platform. Microsoft's answer to Adobe Air is Silverlight, but it's almost a dead technology. is actionscript 3.0 AIR suitable for business applications or i should recreate my program in C#? This is very subjective. It depends on you and your actual goals. There're many WPF/Silverlight/Windows Forms business applications, and also ones made on top of Air. It's not the tool. It's about who uses t

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.